Here you can find the source of getFirstMatchedValueByChildTagName(Node parent, String name)
public static String getFirstMatchedValueByChildTagName(Node parent, String name)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static String getFirstMatchedValueByChildTagName(Node parent, String name) { //List<Element> nodeList = new ArrayList<Element>(); for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { //System.out.println(child.getNodeName()); if (child.getNodeType() == Node.ELEMENT_NODE) { if (child.getNodeName().indexOf(name) != -1) { return child.getTextContent(); } else { String value = getFirstMatchedValueByChildTagName((Element) child, name); if (value != null) { return value; }/*ww w.ja v a 2s .co m*/ } } } return null; } }