The list of methods to do XML Element Root are organized into topic(s).
Element
createRoot(Document document, String title) create Root
Element node = document.createElement(title);
node.setAttribute("xmlns", "http://www.supermap.com.cn/desktop");
node.setAttribute("version", "9.0.x");
document.appendChild(node);
return node;
Element
createRootElement(Document doc, String rootTagName) Create an root element with the specified name
if (doc.getDocumentElement() == null) {
Element root = doc.createElement(rootTagName);
doc.appendChild(root);
return root;
return doc.getDocumentElement();
Node
getElement(String elementName, Node rootNode) get Element
Node node = rootNode.getFirstChild();
while (node != null) {
if (node.getNodeName().equalsIgnoreCase(elementName)) {
return node;
node = node.getNextSibling();
return null;
...
String
getElementValue(Element root, String name) get Element Value
try {
return root.getElementsByTagName(name).item(0).getTextContent();
} catch (Exception e) {
if (DEBUG) {
System.out.println("element: " + name);
System.out.println(printXML(root));
throw e;
...
long
getElementValueLong(Element root, String name) get Element Value Long
String value = getElementValue(root, name).trim();
if (value.length() == 0 || "null".equalsIgnoreCase(value))
return 0;
if ("unlimited".equalsIgnoreCase(value))
return Long.MAX_VALUE;
try {
return Long.parseLong(value);
} catch (Exception e) {
...