Java tutorial
//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; } Node item = nl.item(0); return (Element) item; } }