Android Utililty Methods XML Document Search

List of utility methods to do XML Document Search

Description

The list of methods to do XML Document Search are organized into topic(s).

Method

NodegetFirstElementByTagName(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;
StringgetString(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"); 
ListgetStringDataAsList(Document vastDoc, String elementName)
get String Data As List
return getStringDataAsList(vastDoc, elementName, null, null);
ListgetStringDataAsList(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) {
...
IntegergetInteger(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");