List of utility methods to do XML Document Search
Node | getFirstElementByTagName(Document doc, String name) get First Element By Tag Name NodeList nodes = doc.getElementsByTagName(name); if (nodes != null && nodes.getLength() > 0) return nodes.item(0); return null; |
String | getString(Document doc, String tagName) get String NodeList values = doc.getDocumentElement().getElementsByTagName( tagName); if (values.getLength() == 1) { return values.item(0).getTextContent(); throw new Exception("more than one " + tagName + " elements"); |
List | getStringDataAsList(Document vastDoc, String elementName) get String Data As List return getStringDataAsList(vastDoc, elementName, null, null);
|
List | getStringDataAsList(Document vastDoc, String elementName, String attributeName, String attributeValue) get String Data As List ArrayList<String> results = new ArrayList(); if (vastDoc != null) { NodeList nodes = vastDoc.getElementsByTagName(elementName); if (nodes != null) { int i = 0; while (i < nodes.getLength()) { Node node = nodes.item(i); if (node != null) { ... |
Integer | getInteger(Document doc, String tagName) get Integer NodeList values = doc.getDocumentElement().getElementsByTagName( tagName); if (values.getLength() == 1) { return Integer.parseInt(values.item(0).getTextContent()); throw new Exception("more than one " + tagName + " elements"); |