Java tutorial
//package com.java2s; import org.w3c.dom.Attr; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static void setTTestSetSampleSignificane(Node sampleNode, boolean different, double level) { Attr attr = sampleNode.getOwnerDocument().createAttribute("ttest"); Attr attrLevel = sampleNode.getOwnerDocument().createAttribute("ttest-level"); if (different) attr.setNodeValue("H1"); else attr.setNodeValue("H0"); // System.out.println(attr.getNodeValue()); attrLevel.setNodeValue(level + ""); Element e = (Element) sampleNode; e.setAttributeNode(attr); e.setAttributeNode(attrLevel); } }