Here you can find the source of getFirstChild(Element elem, String childTag)
Parameter | Description |
---|---|
elem | a parameter |
childTag | a parameter |
public static Element getFirstChild(Element elem, String childTag)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/*from w w w . java 2s. co m*/ * @param elem * @param childTag * @return */ public static Element getFirstChild(Element elem, String childTag) { if (elem.hasChildNodes()) { NodeList list = elem.getElementsByTagName(childTag); int count = list.getLength(); for (int i = 0; i < count; i++) { Node node = list.item(i); if (node.getParentNode() != elem) continue; if (node.getNodeType() == Node.ELEMENT_NODE) { return (Element) node; } } } return null; } }