Java tutorial
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.w3c.dom.NodeList; public class Main { /** * Get the value of the first tag found with the given name in the given document<br/>. * * @param doc * @param tagName * @return the value of the node or the empty string, if no node with this name exits in this document */ public static String getTagValue(Document doc, String tagName) { NodeList tagList = doc.getElementsByTagName(tagName); if (tagList.getLength() > 0) { return tagList.item(0).getFirstChild().getNodeValue().trim(); } return ""; } }