Here you can find the source of getFirstChildByName(Element parent, String name)
Parameter | Description |
---|---|
parent | parent element |
name | child element name |
public static Element getFirstChildByName(Element parent, String name)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; public class Main { /**/* w ww. j a va2 s . co m*/ * Return the first child element with a given name. * @param parent parent element * @param name child element name * @return */ public static Element getFirstChildByName(Element parent, String name) { NodeList children = parent.getElementsByTagName(name); if (children.getLength() == 0) { return null; } return (Element) children.item(0); } }