Here you can find the source of getFirstChildElement(Element ele)
Parameter | Description |
---|---|
ele | a parameter |
public static Element getFirstChildElement(Element ele)
//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 va2 s. c o m * a utility method for finding the first child XML element of given XML element * * @param ele * @return */ public static Element getFirstChildElement(Element ele) { Element resultEle = null; NodeList childNodes = ele.getChildNodes(); if (childNodes != null) { for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { resultEle = (Element) node; break; } } } return resultEle; } }