Here you can find the source of firstChildByTagName(Node root, String tagName)
public static Node firstChildByTagName(Node root, String tagName)
//package com.java2s; import org.w3c.dom.Node; public class Main { public static Node firstChildByTagName(Node root, String tagName) { if (root != null && root.getChildNodes().getLength() > 0) { int childCount = root.getChildNodes().getLength(); for (int i = 0; i < childCount; i++) { if (tagName.equals(root.getChildNodes().item(i).getNodeName())) { return root.getChildNodes().item(i); }/* w w w. ja va 2s.c om*/ } } return null; } }