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

NodegetChild(Node node, String tag)
get Child
if (node == null) {
    return null;
NodeList childNodes = node.getChildNodes();
if (childNodes == null) {
    return null;
for (int i = 0; i < childNodes.getLength(); i++) {
...
NodegetChild(Node node, String tag)
get Child
if (node == null) {
    return null;
NodeList childNodes = node.getChildNodes();
if (childNodes == null) {
    return null;
for (int i = 0; i < childNodes.getLength(); i++) {
...
NodegetChild(Node node, String tag)
get Child
if (node == null) {
    return null;
NodeList childNodes = node.getChildNodes();
if (childNodes == null) {
    return null;
for (int i = 0; i < childNodes.getLength(); i++) {
...
NodegetChildElement(Node element, String childNodeName)
get Child Element
for (int i = 0; i < element.getChildNodes().getLength(); i++) {
    Node child = element.getChildNodes().item(i);
    if (child.getNodeName().equals(childNodeName)) {
        return child;
return null;
NodegetChildElement(Node element, String childNodeName)
get Child Element
for (int i = 0; i < element.getChildNodes().getLength(); i++) {
    Node child = element.getChildNodes().item(i);
    if (child.getNodeName().equals(childNodeName)) {
        return child;
return null;
StringgetChildElementText(Node element, String childNodeName)
get Child Element Text
Node child = getChildElement(element, childNodeName);
if (child != null) {
    return child.getTextContent();
return null;
StringgetChildElementText(Node element, String childNodeName)
get Child Element Text
Node child = getChildElement(element, childNodeName);
if (child != null) {
    return child.getTextContent();
return null;
CollectiongetChildElements(Node node)
get Child Elements
List elements = new ArrayList();
NodeList nodes = node.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
    Node childNode = nodes.item(i);
    if (childNode instanceof Element) {
        elements.add(childNode);
return elements;
ListgetChildElementsByName(Element parent, String name)
get Child Elements By Name
List<Element> result = new ArrayList<Element>();
NodeList childNodes = parent.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
    Node child = childNodes.item(i);
    if (child.getNodeType() != Node.ELEMENT_NODE) {
        continue;
    String nodeName = child.getNodeName();
...
Node[]getChildNodes(Node node, short type)
get Child Nodes
NodeList children = node.getChildNodes();
if (children == null)
    return new Node[0];
List<Node> elnodelist = new ArrayList<Node>();
int i, n = children.getLength();
Node childnode;
for (i = 0; i < n; ++i) {
    childnode = children.item(i);
...