Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node findChildWithTagName(Node parent, String tagName) { if (parent == null) { return null; } NodeList childs = parent.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node child = childs.item(i); if (child.getNodeName().equals(tagName)) { return child; } else if (child.hasChildNodes()) { Node result = findChildWithTagName(child, tagName); if (result != null) { return result; } } } return null; } }