Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Element getChildElementNodeByName(Node node, String name) { if (node == null) { return null; } NodeList nodeList = node.getChildNodes(); if (nodeList != null && nodeList.getLength() > 0) { for (int i = 0; i < nodeList.getLength(); i++) { Node item = nodeList.item(i); if (item != null && (node.getNodeType() == Node.ELEMENT_NODE || node.getNodeType() == Node.DOCUMENT_NODE) && name.equalsIgnoreCase(item.getNodeName())) { return (Element) item; } } } return null; } }