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 getValue(Element e, String tagName) { try { // get node lists of a tag name from a Element NodeList elements = e.getElementsByTagName(tagName); if (elements.getLength() == 0) { return null; } Node node = elements.item(0); return node.getTextContent(); } catch (Exception ex) { ex.printStackTrace(); } return null; } }