Here you can find the source of getFirstElement(Element element, String childName)
static Element getFirstElement(Element element, String childName)
//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 { static Element getFirstElement(Element element, String childName) { NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child instanceof Element && ((Element) child).getTagName().equals(childName)) { return (Element) child; }// w ww . j a va2s . c o m } return null; } }