Here you can find the source of getFirstElementByTagName(Document doc, String name)
public static Node getFirstElementByTagName(Document doc, String name)
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Node getFirstElementByTagName(Document doc, String name) { NodeList nodes = doc.getElementsByTagName(name); if (nodes != null && nodes.getLength() > 0) return nodes.item(0); return null; }// ww w. j a v a 2s .c om }