List of utility methods to do XML Element Create
void | addNewElementWithAttribute(Document xmlDoc, Node node, String elementName, String elementValue, String attrName, String attrValue) add New Element With Attribute Node newVal = xmlDoc.createElement(elementName); Node newValText = xmlDoc.createTextNode(elementValue); newVal.appendChild(newValText); addAttribute(xmlDoc, newVal, attrName, attrValue); node.appendChild(newVal); |
Element | createChildElement(Document doc, Element parent, String name, String textValue, String[] attributeNames, String[] attributeValues) This method is used to create an element with Attributes. Element newElem = doc.createElement(name); if (textValue != null) { newElem.appendChild(doc.createTextNode(textValue)); for (int i = 0; i < attributeNames.length; i++) { newElem.setAttribute(attributeNames[i], attributeValues[i]); parent.appendChild(newElem); ... |
Node | createChildInternal(Document document, Node parent, String nodeName, String... attr_name_and_value) create Child Internal Element newNode = document.createElement(nodeName); for (int i = 0; i < attr_name_and_value.length; i += 2) { String attrName = attr_name_and_value[i]; String attrValue = attr_name_and_value[i + 1]; newNode.setAttribute(attrName, attrValue); parent.appendChild(newNode); return newNode; ... |
Comment | createComment(Element parent, String str) Creates a DOM comment Document doc = parent.getOwnerDocument();
Comment c = doc.createComment(str);
parent.appendChild(c);
return c;
|
Element | createElement(Document d, String name, String value) create Element Element e = d.createElement(name);
e.appendChild(d.createTextNode(value));
return e;
|
Element | createElement(Document d, String name, String value, boolean isCDATA) Creates a DOM element node with the given name and contents. Element e = createElement(d, name); if (isCDATA) e.appendChild(createCDATA(d, value)); else e.appendChild(createText(d, value)); return e; |
Element | createElement(Document d, String tagName) create Element Element e = d.createElement(tagName);
return e;
|
Element | createElement(Document doc, Node parent, int depth, String name, String contents) Creates an element in the specified document, the created element has a single text node child with the specified contents. Element result = createElement(doc, parent, depth, name);
createText(doc, result, contents);
return result;
|
Element | createElement(Document doc, Node parent, String tagName) create Element Element e = doc.createElement(tagName);
parent.appendChild(e);
return e;
|
Element | createElement(Document doc, String elementNamespace, String elementName) create Element Element element = doc.createElementNS(elementNamespace, elementName);
return element;
|