Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static synchronized Element getChildElement(Element element, String childName) { if (element == null || childName == null || childName.length() == 0) { return null; } Element childs = null; for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Element) { if (node.getNodeName().equals(childName)) { childs = (Element) node; break; } } } return childs; } public static synchronized Element getChildElement(Element element) { if (element == null) { return null; } Element childs = null; for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) { if (node instanceof Element) { childs = (Element) node; break; } } return childs; } }