Java tutorial
//package com.java2s; // Released under the terms of the CPL Common Public License version 1.0. import org.w3c.dom.*; public class Main { public static String getTextValue(Element element, String name) { Element namedElement = getElementByTagName(element, name); return getElementText(namedElement); } public static Element getElementByTagName(Element element, String name) { NodeList nodes = element.getElementsByTagName(name); if (nodes.getLength() == 0) return null; else return (Element) nodes.item(0); } public static String getElementText(Element namedElement) { if (namedElement == null) { return null; } String text = namedElement.getTextContent(); return (text.isEmpty()) ? null : text; } }