Here you can find the source of getChildElement(final Element parent, final String childName)
Parameter | Description |
---|---|
parent | the parent XML element |
childName | the child node name |
null
if does not exist
public static Element getChildElement(final Element parent, final String childName)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**/* www. jav a 2 s . com*/ * @param parent the parent XML element * @param childName the child node name * @return the child XML element with specified node name or <code>null</code> if does not exist */ public static Element getChildElement(final Element parent, final String childName) { Element child = null; if (parent != null) { NodeList children = parent.getElementsByTagName(childName); if (children.getLength() > 0) { child = (Element) children.item(0); } } return child; } }