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 getElementText(final Element eElement, final String name) { NodeList nodes = eElement.getElementsByTagName(name); if (nodes == null) { return null; } Node node = nodes.item(0); if (node == null) { return null; } String value = node.getTextContent(); return (value != null) ? value.trim() : null; } }