List of utility methods to do XML Child Element Create
Element | createChild(Node node, String elemName) Creates a new Node -object with the specified name and appends it as a child element to the provided Node - parameter.
if (node == null || elemName == null || "".equals(elemName)) throw new IllegalArgumentException("Arguments are not allowed to be null or empty"); Document document = null; if (node instanceof Document) { document = (Document) node; } else if (node.getOwnerDocument() != null) { document = node.getOwnerDocument(); Element newChild = null; if (document != null) { newChild = document.createElement(elemName); node.appendChild(newChild); return newChild; |
Element | createChildElement(Document doc, Element parent, String name) This method is used to create a Child element. Element newElem = doc.createElement(name);
parent.appendChild(newElem);
return newElem;
|
Element | createChildElement(Document doc, Node node, String nodeName) Create a child of the given node. Element element = doc.createElement(nodeName);
node.appendChild(element);
return element;
|
Element | createChildElement(Element parent, String name) Creates a named Element and appends it to the given element, returns it. Document doc = parent.getOwnerDocument();
Element e = doc.createElement(name);
parent.appendChild(e);
return e;
|
Element | createChildElement(Element parentElement, String elementName) create Child Element Element child = parentElement.getOwnerDocument().createElement(elementName);
parentElement.appendChild(child);
return child;
|
Element | createChildElement(Element parentElement, String strTagName) create Child Element Element eleChildElement = parentElement.getOwnerDocument().createElement(strTagName);
parentElement.appendChild(eleChildElement);
return eleChildElement;
|
Element | createChildElement(final String tagName, final Node parent, final Document document) Creates a child element with the given name and parent. final Element child = document.createElement(tagName); parent.appendChild(child); return child; |
Element | createChildElement(String tagName, Element parentElement) create Child Element Element result = parentElement.getOwnerDocument().createElement(tagName);
parentElement.appendChild(result);
return result;
|
Element | createTextChild(Node elem, String elemName, Boolean text) create Text Child return createTextChild(elem, elemName, text == null ? "false" : text.toString()); |
Element | getChildElementByChain(Element element, String[] chain, boolean create) Returns the element which is at the end of the specified chain if (chain == null) return null; Element e = element; for (int i = 0; i < chain.length; i++) { if (e == null) return null; e = getChildElementByTagName(e, chain[i]); return e; |