Here you can find the source of getFirstChildElement(final Node parent, final String elemName)
public static Element getFirstChildElement(final Node parent, final String elemName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getFirstChildElement(final Node parent, final String elemName) { for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { final short nodeType = child.getNodeType(); if (nodeType == Node.ELEMENT_NODE) { final String nodeName = child.getNodeName(); if (nodeName.equals(elemName)) { return (Element) child; }//from ww w . j a va 2 s . c om } } return null; } }