Here you can find the source of getElementByTagName(Document doc, String eleName)
public static Element getElementByTagName(Document doc, String eleName)
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static Element getElementByTagName(Document doc, String eleName) { NodeList nl = doc.getElementsByTagName(eleName); if (null == nl) { return null; }//from w w w . j a va2 s.c o m Node item = nl.item(0); return (Element) item; } }