Here you can find the source of getValue(Element element, String elementName)
public static String getValue(Element element, String elementName)
//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 element, String elementName) { NodeList elements = element.getElementsByTagName(elementName); if (1 != elements.getLength()) { throw new IllegalStateException( "TODO: handle when elements does not contain exactly one item.elementName=" + elementName); }/*w w w . j ava 2 s. c o m*/ Node elementNode = elements.item(0); NodeList children = elementNode.getChildNodes(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < children.getLength(); i++) { String value = children.item(i).getNodeValue(); sb.append(value); } return sb.toString(); } }