Java tutorial
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getStringValueForXMLTag(Element xmlElement, String key) { NodeList nl = xmlElement.getElementsByTagName(key); if (nl.getLength() > 0) { Node node = nl.item(0).getFirstChild(); if (node != null) { String output = node.getNodeValue().trim(); return output; } } return ""; } }