List of usage examples for org.w3c.dom Node getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:Main.java
public static void setAttribute(Node node, String key, String value) { Node attributeNode = node.getOwnerDocument().createAttribute(key); attributeNode.setNodeValue(value);//w w w . ja v a 2 s. com node.getAttributes().setNamedItem(attributeNode); }
From source file:Main.java
public static void tTestSetSampleSignificane(Node sampleNode, boolean different) { Attr attr = sampleNode.getOwnerDocument().createAttribute("ttest"); if (different) attr.setNodeValue("H1"); else/* w ww . j a v a 2s . c o m*/ attr.setNodeValue("H0"); // System.out.println(attr.getNodeValue()); Element e = (Element) sampleNode; e.setAttributeNode(attr); e.removeAttribute("ttest-level"); }
From source file:Main.java
public static void addTextTag(Node node, String tagName, String text) { Document doc = node.getOwnerDocument(); Element elem = doc.createElement(tagName); elem.appendChild(doc.createTextNode(text)); node.appendChild(elem);//ww w . j ava2s . co m }
From source file:Main.java
public static Node appendForeignChild(Node node, Node foreignChild) { return node.appendChild(node.getOwnerDocument().importNode(foreignChild, true)); }
From source file:Main.java
public static void appendCollection(Node node, Object[] o, String tag) { Element child = node.getOwnerDocument().createElement(tag); for (int i = 0; i < o.length; i++) { child.setAttribute("element_" + i, (String) o[i]); }//from w w w .ja v a2 s. c o m node.appendChild(child); }
From source file:Main.java
public static void createNewCDATA(Node elem, String value) { Document doc = elem.getOwnerDocument(); if (value == null) { value = ""; }//w ww.j a v a 2s. c om CDATASection cdata = doc.createCDATASection(value); elem.appendChild(cdata); }
From source file:Main.java
public static Element addElement(Node parent, String name) { Element node;/*from w w w . j a v a2 s.co m*/ if (parent.getOwnerDocument() != null) node = parent.getOwnerDocument().createElement(name); else if (parent instanceof Document) node = ((Document) parent).createElement(name); else return null; parent.appendChild(node); return node; }
From source file:Main.java
public static void saveAttributesToNode(Node node, Properties props) { Document doc = node.getOwnerDocument(); Element elem;// w ww. j av a2 s .c o m Enumeration keys = props.keys(); Enumeration elems = props.elements(); while (keys.hasMoreElements()) { String s; s = keys.nextElement().toString() + "=" + elems.nextElement().toString(); addTextTag(node, TAG_ATTR, s); } }
From source file:Main.java
public static Node addTextTag(Node parent, String name, String value) { Node node = parent.getOwnerDocument().createElement(name); parent.appendChild(node);/*from w w w . j av a2 s. co m*/ Text text = parent.getOwnerDocument().createTextNode(value); node.appendChild(text); return node; }
From source file:Main.java
public static Attr addAttribute(Node parent, String name, String value) { Attr node = parent.getOwnerDocument().createAttribute(name); node.setValue(value);// w w w.j a v a2 s.com parent.getAttributes().setNamedItem(node); return node; }