Here you can find the source of getChildElement(Node parent, QName childNamespace)
public static Element getChildElement(Node parent, QName childNamespace)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import javax.xml.namespace.QName; public class Main { public static Element getChildElement(Node parent, QName childNamespace) { if (parent != null) { NodeList children = parent.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (isElement(child) && matches(child, childNamespace.getLocalPart(), childNamespace)) { return (Element) child; }/* w w w . j a v a 2 s. c om*/ } } return null; } private static boolean isElement(Node node) { return node.getNodeType() == Node.ELEMENT_NODE; } public static boolean matches(Node node, String requiredLocalName, QName requiredNamespace) { if (node == null) { return false; } boolean matchingNamespace = matchingNamespace(node, requiredNamespace); return matchingNamespace && matchingLocalName(node, requiredLocalName); } private static boolean matchingNamespace(Node node, QName requiredNamespace) { if (requiredNamespace == null) { return true; } else { return requiredNamespace.getNamespaceURI().equals(node.getNamespaceURI()); } } private static boolean matchingLocalName(Node node, String requiredLocalName) { if (requiredLocalName == null) { return true; } else { String localName = node.getLocalName(); return requiredLocalName.equals(localName); } } }