List of usage examples for org.w3c.dom Element getOwnerDocument
public Document getOwnerDocument();
Document
object associated with this node. From source file:Main.java
/** * Create a new element and add it as the first child * * @param parent//from w w w .j a v a2 s. c om * the parent to which to add the element * @param name * the name of the element * @return the new element */ public static Element addElementFirst(final Element parent, final String name) { final Element ele = parent.getOwnerDocument().createElement(name); parent.insertBefore(ele, null); return ele; }
From source file:Main.java
public static Element createElementNsIn(Element parent, String ns, String name, String textContent) { Element el = parent.getOwnerDocument().createElementNS(ns, name); parent.appendChild(el);/*from w w w . jav a 2 s . c om*/ el.setTextContent(textContent); return el; }
From source file:Main.java
/** * Appends the child element to the parent element. * * @param parent the parent element//from ww w . j av a2s . co m * @param tagName the child element name * @return the child element added to the parent element */ public static Element appendElement(Element parent, String tagName) { Element child = parent.getOwnerDocument().createElement(tagName); parent.appendChild(child); return child; }
From source file:Main.java
public static Element addChildElement(Element element, String name, String text) { Document document = element.getOwnerDocument(); Element result = (Element) element.appendChild(document.createElement(name)); if (text != null) result.appendChild(document.createTextNode(text)); return result; }
From source file:Main.java
public static void appendStringAttribute(Element thisElem, String attrName, String attrValue) { Attr attr = thisElem.getOwnerDocument().createAttribute(attrName); attr.setTextContent(attrValue);// w w w. j ava 2 s . c om thisElem.setAttributeNode(attr); }
From source file:Main.java
public static Element createChildElement(Element parentElement, String strTagName) { Element eleChildElement = parentElement.getOwnerDocument().createElement(strTagName); parentElement.appendChild(eleChildElement); return eleChildElement; }
From source file:Main.java
/** * Appends a text node with the given information to the specified DOM * element./*from w ww . ja v a 2s . com*/ */ public static Text createText(final Element el, final String info) { final Text text = el.getOwnerDocument().createTextNode(info); el.appendChild(text); return text; }
From source file:Main.java
/** * Appends a child element with the given name to the specified DOM element. *///from ww w . ja v a2 s . co m public static Element createChild(final Element el, final String name) { final Element child = el.getOwnerDocument().createElement(name); el.appendChild(child); return child; }
From source file:Main.java
static public Element addChildElement(Element parentElement, String elementName) { Element childElement = parentElement.getOwnerDocument().createElement(elementName); parentElement.appendChild(childElement); return childElement; }
From source file:Main.java
public static void insertValue(Element parent, String childName, String childNamespace, String value) { Element child = parent.getOwnerDocument().createElementNS(childNamespace, childName); child.setTextContent(value);/* w ww . j a v a 2 s . co m*/ parent.appendChild(child); }