Java tutorial
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Get fisrt specified child node by tag name. * * @param parent * the parent node * @param tagName * the tag name * @return the child node * @throws Exception * on error */ public static Node getFirstChildNode(Node parent, String tagName) throws Exception { if (null != parent) { NodeList childrenList = parent.getChildNodes(); int childrenCnt = childrenList.getLength(); for (int i = 0; i < childrenCnt; i++) { Node child = childrenList.item(i); if (child.getNodeName().equals(tagName)) { return child; } } } return null; } }