Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** * Gets the first element of a Node * @param parent Node * @return first element of a Node */ public static Element getFirstElement(Node parent) { Node n = parent.getFirstChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getNextSibling(); } if (n == null) { return null; } return (Element) n; } }