List of utility methods to do XML Element Create
Element | createElementNS(String namespaceURI, String qualifiedName, String text, Document doc) create Element NS if (namespaceURI == null) return createElement(qualifiedName, text, doc); else { Element elem = doc.createElementNS(namespaceURI, qualifiedName); if ((text != null) && !text.equals("")) elem.appendChild(doc.createTextNode(text)); return elem; |
Element | createElementNsIn(Element parent, String ns, String name, String textContent) create Element Ns In Element el = parent.getOwnerDocument().createElementNS(ns, name);
parent.appendChild(el);
el.setTextContent(textContent);
return el;
|
Element | createElementWithText(Element parent, String name, String value) helper method, creates a subelement with text embedded. Document doc = parent.getOwnerDocument();
Element newElement = doc.createElement(name);
parent.appendChild(newElement);
newElement.appendChild(doc.createTextNode(value));
return newElement;
|
Element | createElmWithText(Document doc, String tagName, String text) create Elm With Text Element elm = doc.createElement(tagName); text = text != null ? text.trim() : ""; Node node = (text.indexOf('<') >= 0 || text.indexOf('\n') >= 0) ? doc.createCDATASection(text) : doc.createTextNode(text); elm.appendChild(node); return elm; |
Element | createNewElementAndSetAndAttribute(Document document, Element parent, String childElement, String childValue, String attributeName, String attributeValue) create New Element And Set And Attribute Element child = createNewElementAndSet(document, parent, childElement, childValue);
child.setAttribute(attributeName, attributeValue);
return child;
|
Element | createNode(Document doc, Element parent, String nodeName, Object[] attr) Create a new node with parent element Element elem = doc.createElement(nodeName); for (int i = 0; i < attr.length; i += 2) { elem.setAttribute(attr[i].toString(), attr[i + 1].toString()); parent.appendChild(elem); return elem; |
Element | createNode(Document doc, Element parent, String nodeName, Object[] attr) Create a new node with parent element Element elem = doc.createElement(nodeName); for (int i = 0; i < attr.length; i += 2) { elem.setAttribute(attr[i].toString(), attr[i + 1].toString()); parent.appendChild(elem); return elem; |
Element | createTable(Element theParent) create Table Element aElem = theParent.getOwnerDocument().createElement("table"); aElem.setAttribute("border", "0"); aElem.setAttribute("cellspacing", "0"); aElem.setAttribute("cellpadding", "0"); theParent.appendChild(aElem); return aElem; |
Text | createText(final Node parent, final String text) Creates the text. final Text child = parent.getOwnerDocument().createTextNode(text); parent.appendChild(child); return child; |
Element | createText(Node parent, String tag, String text) create Text Element e = createElement(parent, tag);
Node t = parent.getOwnerDocument().createTextNode(text);
e.appendChild(t);
return e;
|