Here you can find the source of getFirstChildElement(Node node)
Node
.
Parameter | Description |
---|---|
node | the <code>Node</code> to search |
Element
of the given Node
public static Element getFirstChildElement(Node node)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// ww w . j a v a2 s.c o m * Gets the first child {@link org.w3c.dom.Element} of the given <code>Node</code>. * * @param node the <code>Node</code> to search * @return the first child <code>Element</code> of the given <code>Node</code> */ public static Element getFirstChildElement(Node node) { NodeList children = null; int numChildren = 0; if (node == null || (children = node.getChildNodes()) == null || (numChildren = node.getChildNodes().getLength()) == 0) { return null; } Element result = null; for (int i = 0; i < numChildren && result == null; i++) { Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { result = (Element) child; } } return result; } }