Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { public static String getTagValue(String tag, Element elem) { String retVal = ""; NodeList fstNmElmntLst = elem.getElementsByTagName(tag); Element fstNmElmnt = (Element) fstNmElmntLst.item(0); if (fstNmElmnt == null) return ""; NodeList fstNm = fstNmElmnt.getChildNodes(); if (fstNm == null || fstNm.item(0) == null) return ""; retVal = fstNm.item(0).getNodeValue(); return retVal; } }