Here you can find the source of getFirstChildElement(Node start)
public static Element getFirstChildElement(Node start)
//package com.java2s; /*//from w w w. ja va 2 s . c o m * Copyright (c) 2012. betterFORM Project - http://www.betterform.de * Licensed under the terms of BSD License */ import org.w3c.dom.*; public class Main { /** * gets the first child of a node which is an element. This avoids the whitespace problems when using * org.w3c.dom.node.getFirstChild(). Whitespace-nodes may also appear as children, but normally are not what you're * looking for. */ public static Element getFirstChildElement(Node start) { Node n = null; NodeList nl = start.getChildNodes(); int len = nl.getLength(); if (len == 0) { return null; } for (int i = 0; i < len; i++) { n = nl.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { return ((Element) n); } } return null; } }