Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /** * Gets the first child Element with a given name * * @param n the node get the children from * @param elementName the name of the child elements * @return the first child Element with a given name */ public static Element getElementByTagName(Element n, String elementName) { NodeList subNodes = n.getElementsByTagName(elementName); int sz = subNodes.getLength(); if (sz > 0) { return (Element) subNodes.item(0); } return null; } }