List of usage examples for org.w3c.dom Element appendChild
public Node appendChild(Node newChild) throws DOMException;
newChild
to the end of the list of children of this node. From source file:Main.java
public static Element createElement(final String namespace, final String localPart, final String value) { if (document == null) { throw new RuntimeException("XMLDocumentBuilder could not be initialized"); }//ww w . j ava2 s. c om Element element = document.createElementNS(namespace, "ns:" + localPart); element.appendChild(document.createTextNode(value)); return element; }
From source file:Main.java
public static void addChild(final Document doc, Element parent, final String childName, final String childValue) { Element child = doc.createElement(childName); Text text = doc.createTextNode(childValue); child.appendChild(text); parent.appendChild(child);//from w w w .j a v a2 s . c o m }
From source file:Main.java
/** * * @param doc Document// w ww. j a va 2 s . c o m * @param parent Node * @param name String * @param value int * @return Element */ public static Element appendChildNode(Document doc, Node parent, String name, int value) { Element child = doc.createElement(name); child.appendChild(doc.createTextNode(new Integer(value).toString())); parent.appendChild(child); return child; }
From source file:Main.java
/** * * @param doc Document/*from w w w . ja va 2 s . c o m*/ * @param parent Node * @param name String * @param value String * @return Element */ public static Element appendChildNode(Document doc, Node parent, String name, String value) { Element child = doc.createElement(name); child.appendChild(doc.createTextNode(value)); parent.appendChild(child); return child; }
From source file:Main.java
public static Element writeFloatElement(Document document, String name, float value, Element parentElement) { Element element = document.createElement(name); Text text = document.createTextNode(Float.toString(value)); element.appendChild(text); parentElement.appendChild(element);//w w w. j ava2 s. c o m return element; }
From source file:Main.java
public static Element createTextElement(Document document, String tag, String text) { if (document == null || tag == null || text == null) { return null; }//from w w w . j a va 2 s. co m Element element = document.createElement(tag); Text textNode = document.createTextNode(text); element.appendChild(textNode); return element; }
From source file:Main.java
public static void appendElement(Element parent, Element child) { Node tmp = parent.getOwnerDocument().importNode(child, true); parent.appendChild(tmp); }
From source file:Main.java
public static Element createNewCDATAElement(Node elem, String tag, String value) { Document doc = elem.getOwnerDocument(); Element res = doc.createElement(tag); CDATASection cdata = doc.createCDATASection(value); res.appendChild(cdata); elem.appendChild(res);// w w w .ja va 2s . c o m return res; }
From source file:Main.java
public static Element createElementNsIn(Element parent, String ns, String name) { Element el = parent.getOwnerDocument().createElementNS(ns, name); parent.appendChild(el); return el;/* w w w. j a v a2 s.co m*/ }
From source file:Main.java
/** * creates two elements: - one for the tag - one for the value and appends the * value as the child of the tag element returns a reference to the tag * element. Both elements are created in the document. *///from w w w. j a v a 2s .c om public static Element createTaggedElement(Document doc, String tag, String value) { Element tagElement = doc.createElement(tag); Text valueElement = doc.createTextNode(value); tagElement.appendChild(valueElement); return tagElement; }