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 tTestSetSampleSignificane(Node sampleNode, boolean different) { Attr attr = sampleNode.getOwnerDocument().createAttribute("ttest"); if (different) attr.setNodeValue("H1"); else attr.setNodeValue("H0"); // System.out.println(attr.getNodeValue()); Element e = (Element) sampleNode; e.setAttributeNode(attr); e.removeAttribute("ttest-level"); } }