List of usage examples for org.w3c.dom Node 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
/** Add a Text element to a Document */ public static Text addChildTextElement(Document doc, Node parent, String tag, String value) { Element e = doc.createElement(tag); Text t = doc.createTextNode(value); e.appendChild(t);//from ww w .jav a 2 s . c o m parent.appendChild(e); return t; }
From source file:Main.java
public static void addDataText1(Document doc, Node parent, String elementName, String elementData) { Element e = doc.createElement(elementName); e.appendChild(doc.createTextNode(elementData)); parent.appendChild(e); }
From source file:Main.java
/** * * @param doc Document/*from ww w. ja va 2s . c o m*/ * @param namespace String * @param parent Node * @param name String * @return Element */ public static Element appendChildNode(Document doc, String namespace, Node parent, String name) { Element child = doc.createElementNS(namespace, name); parent.appendChild(child); return child; }
From source file:Main.java
public static void appendChild(Document document, Node root, String nsURI, String name, String value) { Node node = document.createElementNS(nsURI, name); node.appendChild(document.createTextNode(value != null ? value : "")); root.appendChild(node);//from ww w . j av a2 s . c om return; }
From source file:Main.java
/** * Append node./*ww w . j a va2 s. com*/ * * @param baseNode * the base node * @param tagName * the tag name * @return the element */ public static Element appendNode(Node baseNode, String tagName) { Element newNode = baseNode.getOwnerDocument().createElement(tagName); baseNode.appendChild(newNode); return newNode; }
From source file:Main.java
/** * This method creates a new textnode with the passed on value. * * @param sValue The value for the new textnode. * @param nParent The parent node./*from w w w . j av a2 s . c o m*/ */ public static void createText(String sValue, Node nParent) { if (nParent != null) { Document dDoc = nParent.getOwnerDocument(); Node nTemp = dDoc.createTextNode(sValue); nParent.appendChild(nTemp); } }
From source file:Main.java
/** * add single element to a node. it doesn't check if an element exists with the same name. * @param contextNode is the node to which the element is added * @param elmName is the new element name, not XPath. * @return the new Element// w w w. j a va 2 s . c o m */ public static Element addSingleElement(Node contextNode, String elmName) throws Exception { Element elm = contextNode.getOwnerDocument().createElement(elmName); contextNode.appendChild(elm); return (elm); }
From source file:Main.java
public static void setFirst(Node parent, Node node) { Node first = parent.getFirstChild(); if (first != null) parent.insertBefore(node, first); else//from w w w.j av a2 s . com parent.appendChild(node); }
From source file:Main.java
/** * * @param doc Document//from w w w . j a v a2s.c o m * @param parent Node * @param name String * @param value String * @return Element */ public static Element appendChildNodeCDATA(Document doc, Node parent, String name, String value) { Element child = doc.createElement(name); child.appendChild(doc.createCDATASection(value)); parent.appendChild(child); return child; }
From source file:Main.java
/** * Appends a child to the given xml Node * //from w ww .ja va 2 s . c o m * @param xml the parent Node * @param child the child Node to append to parent **/ public final static void appendChild(final Node xml, final Node child) { if ((xml == null) || (child == null)) { return; } xml.appendChild(child); }