Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import java.util.Collection; public class Main { public static Element getChildElementByTagName(Element ele, String childEleName) { NodeList nl = ele.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node node = nl.item(i); if (node instanceof Element && nodeNameMatch(node, childEleName)) { return (Element) node; } } return null; } private static boolean nodeNameMatch(Node node, Collection<?> desiredNames) { return (desiredNames.contains(node.getNodeName()) || desiredNames.contains(node.getLocalName())); } private static boolean nodeNameMatch(Node node, String desiredName) { return (desiredName.equals(node.getNodeName()) || desiredName.equals(node.getLocalName())); } }