Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { public static Element recuperarReferencia(final Element parent, final String childName) { Element tmpElement = getFirstChildElement(parent); while (tmpElement != null) { if (tmpElement.getTagName().equals(childName)) { return tmpElement; } tmpElement = getNextSiblingElement(tmpElement); } return null; } public static Element getFirstChildElement(final Node parent) { if (parent != null) { Node tmpResult = parent.getFirstChild(); if (tmpResult != null) { if (Node.ELEMENT_NODE == tmpResult.getNodeType()) { return (Element) tmpResult; } else { return getNextSiblingElement(tmpResult); } } } return null; } public static Element getNextSiblingElement(final Node node) { if (node != null) { Node tmpResult = node.getNextSibling(); while (tmpResult != null) { if (Node.ELEMENT_NODE == tmpResult.getNodeType()) { return (Element) tmpResult; } tmpResult = tmpResult.getNextSibling(); } } return null; } }