Here you can find the source of getFirstChild(Element e)
public static Element getFirstChild(Element e)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element getFirstChild(Element e) { if (e == null) return null; Node n = e.getFirstChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getNextSibling();//from w w w .j ava 2 s . c o m return (Element) n; } public static Element getNextSibling(Element e) { Node n = e.getNextSibling(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) n = n.getNextSibling(); return (Element) n; } }