Here you can find the source of getFirstNodeByName(Node root, String tagName)
public static Node getFirstNodeByName(Node root, String tagName)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node getFirstNodeByName(Node root, String tagName) { NodeList nodes;/*from w ww.j a va 2 s .c o m*/ nodes = root.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node n = nodes.item(i); if (n.getNodeName().equals(tagName)) { return n; } } return null; } }