Android XML Node Child Get getChildElementText(Node element, String childNodeName)

Here you can find the source of getChildElementText(Node element, String childNodeName)

Description

get Child Element Text

Declaration

public static String getChildElementText(Node element,
            String childNodeName) 

Method Source Code

//package com.java2s;
import org.w3c.dom.Node;

public class Main {
    public static String getChildElementText(Node element,
            String childNodeName) {
        Node child = getChildElement(element, childNodeName);

        if (child != null) {
            return child.getTextContent();
        }/*  ww w. j av a  2s.  c om*/

        return null;
    }

    public static Node getChildElement(Node element, String childNodeName) {
        for (int i = 0; i < element.getChildNodes().getLength(); i++) {
            Node child = element.getChildNodes().item(i);
            if (child.getNodeName().equals(childNodeName)) {
                return child;
            }
        }

        return null;
    }
}

Related

  1. getChild(Node node, String tag)
  2. getChild(Node node, String tag)
  3. getChildElement(Node element, String childNodeName)
  4. getChildElement(Node element, String childNodeName)
  5. getChildElementText(Node element, String childNodeName)
  6. getChildElements(Node node)
  7. getChildElementsByName(Element parent, String name)
  8. getChildNodes(Node node, short type)
  9. getChildTagValue(Node node, String tag)