List of utility methods to do XML Document Append
Element | appendTextNode(String tagName, String textContent, Document doc) append Text Node Element textNode = doc.createElement(tagName);
textNode.setTextContent(textContent);
return textNode;
|
Node | buildPlayerNode(Document doc, String user, String addy, double lat, double lng) build Player Node Element player = doc.createElement("player"); Node name = doc.createElement("name"); name.setTextContent(user); Node id = doc.createElement("id"); id.setTextContent(addy); Node loc = doc.createElement("location"); Node lati = doc.createElement("lat"); lati.setTextContent(String.valueOf(lat)); ... |
Attr | createAttribute(Document document, String name, String value) create Attribute Attr attr = document.createAttribute(name);
attr.setValue(value);
return attr;
|
Element | createElementWithCDATASection(Document document, String name, String value) create Element With CDATA Section Element element = document.createElement(name);
element.appendChild(document.createCDATASection(value));
return element;
|
Element | createElementWithTextNode(Document document, String name, String value) create Element With Text Node Element element = document.createElement(name);
element.appendChild(document.createTextNode(value));
return element;
|
Element | createNode(Document d, String nameSpace, String name) create Node if (nameSpace == null || nameSpace.length() == 0) return d.createElement(name); Element e = d.createElementNS(nameSpace, name); NamedNodeMap map = d.getDocumentElement().getAttributes(); int i = 0; int n = map.getLength(); for (i = 0; i < n; i++) { Attr attr = (Attr) map.item(i); ... |
Element | createXmlElement(Document xml, Element parent, String name) create Xml Element Element e = xml.createElement(name); try { parent.appendChild(e); } catch (Exception ex) { System.out.println(ex.toString()); return e; |