Android Utililty Methods XML Node Child Get

List of utility methods to do XML Node Child Get

Description

The list of methods to do XML Node Child Get are organized into topic(s).

Method

ArrayListchildren(Node x)
children
ArrayList<Element> a = new ArrayList<Element>();
NodeList nodeList = x.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
    Node n = nodeList.item(i);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        a.add((Element) n);
return a;
ArrayListchildrenOfType(Node x, String s)
children Of Type
ArrayList<Element> a = new ArrayList<Element>();
Node n = x.getFirstChild();
Node last = x.getLastChild();
while (n != null) {
    if (n.getNodeName().equals(s)) {
        a.add((Element) n);
    if (n == last)
...
ElementfirstChildOfType(Node x, String s)
first Child Of Type
if (x != null) {
    Node n = x.getFirstChild();
    Node last = x.getLastChild();
    while (n != null) {
        if (n.getNodeName().equals(s)) {
            return (Element) n;
        if (n == last)
...
ListgetMatchingChildNodes(Node node, String nodeName, String attributeName, List attributeValues)
get Matching Child Nodes
if (node == null || nodeName == null) {
    return null;
List<Node> nodes = new ArrayList();
NodeList nodeList = node.getChildNodes();
int i = 0;
while (i < nodeList.getLength()) {
    Node childNode = nodeList.item(i);
...
ElementfirstDescendantOfType(Node x, String s)
first Descendant Of Type
Node n = firstChildOfType(x, s);
if (n != null)
    return (Element) n;
n = (Element) x.getFirstChild();
Node last = x.getLastChild();
while (n != null) {
    Element k = firstDescendantOfType((Node) n, s);
    if (k != null)
...
StringfirstValueOfType(Node x, String s)
first Value Of Type
Node n = x.getFirstChild();
Node last = x.getLastChild();
while (n != null) {
    if (n.getNodeName().equals(s)) {
        NodeList nodes = n.getChildNodes();
        String result = "";
        for (int i = 0; i < nodes.getLength(); i++) {
            Node m = nodes.item(i);
...
voidgetSet(Node rootNode, Set result, Node exclude, boolean com)
get Set
if ((exclude != null) && isDescendantOrSelf(exclude, rootNode)) {
    return;
getSetRec(rootNode, result, exclude, com);
voidgetSetRec(final Node rootNode, final Set result, final Node exclude, final boolean com)
get Set Rec
if (rootNode == exclude) {
    return;
switch (rootNode.getNodeType()) {
case Node.ELEMENT_NODE:
    result.add(rootNode);
    Element el = (Element) rootNode;
    if (el.hasAttributes()) {
...