Here you can find the source of getFirstElement(Element documentElement)
public static Element getFirstElement(Element documentElement)
//package com.java2s; //License from project: LGPL import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static Element getFirstElement(Element documentElement) { Object node = null;//from w w w . jav a 2 s .c o m NodeList childs = documentElement.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { node = childs.item(i); if (node instanceof Element) return (Element) node; } throw new RuntimeException("Can't find any Element"); } }