Here you can find the source of getFirstChild(Element root, String name)
public static Element getFirstChild(Element root, String name)
//package com.java2s; import org.w3c.dom.*; public class Main { /**/* w w w .j av a 2 s . com*/ * Returns the first node that is a direct child of root with the coresponding * name. Does not search children of children. */ public static Element getFirstChild(Element root, String name) { NodeList nl = root.getChildNodes(); int size = nl.getLength(); for (int i = 0; i < size; i++) { Node node = nl.item(i); if (!(node instanceof Element)) continue; Element ele = (Element) node; if (ele.getTagName().equals(name)) return ele; } return null; } }