List of utility methods to do XML Element Create
void | createText(String sValue, Node nParent) This method creates a new textnode with the passed on value. if (nParent != null) {
Document dDoc = nParent.getOwnerDocument();
Node nTemp = dDoc.createTextNode(sValue);
nParent.appendChild(nTemp);
|
Element | createTextElement(Element parent, String tagName, String text) create Text Element Document doc = parent.getOwnerDocument(); Element e = createElement(parent, tagName); if (text == null) { text = ""; e.appendChild(doc.createTextNode(text)); return e; |
Element | createTextElement2(Element parent, String tagName, String text) Creates a DOM text element Document doc = parent.getOwnerDocument();
Element e = doc.createElement(tagName);
e.appendChild(doc.createTextNode(text));
parent.appendChild(e);
return e;
|
Element | findElementElseCreateAndAttribute(Document document, Element parent, String element, String attributeName, String attributeValue) find Element Else Create And Attribute NodeList nl = parent.getElementsByTagName(element); Element e = null; if (nl.getLength() == 0) { parent.appendChild(document.createElement(element)); e = (Element) parent.getElementsByTagName(element).item(0); e.setAttribute(attributeName, attributeValue); return e; ... |
Element | findElementElseCreateAndSetAndAttribute(Document document, Element parent, String element, String value, String attributeName, String attributeValue) find Element Else Create And Set And Attribute Element e = findElementElseCreateAndAttribute(document, parent, element, attributeName, attributeValue); if (e != null) e.appendChild(document.createTextNode(value)); return e; |