Here you can find the source of getFirstLevelChildElementByTagName(Element parent, String elementName)
public static final Element getFirstLevelChildElementByTagName(Element parent, String elementName)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static final Element getFirstLevelChildElementByTagName(Element parent, String elementName) { Node childNode = parent.getFirstChild(); while (childNode != null) { if ((childNode.getNodeType() == Node.ELEMENT_NODE) && ((Element) childNode).getLocalName().equals(elementName)) { return (Element) childNode; }/* w w w. j a v a 2s .c om*/ childNode = childNode.getNextSibling(); } return null; } }