Here you can find the source of getChildByTagName(Element element, String tagName)
public static Element getChildByTagName(Element element, String tagName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Element getChildByTagName(Element element, String tagName) { Element result = null;/* www .j a va 2s . c o m*/ NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node n = childNodes.item(i); if (!(n instanceof Element)) { continue; } if (((Element) n).getTagName().equals(tagName)) { if (result != null) { throw new RuntimeException("Too many elements with tag name " + tagName); } result = (Element) n; } } return result; } }