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 GetStringValueForNode(Node item) throws Exception { if (item instanceof Element) { StringBuilder builder = new StringBuilder(); NodeList children = item.getChildNodes(); for (int index = 0; index < children.getLength(); index++) builder.append(children.item(index).getNodeValue()); // return... return builder.toString(); } else throw new Exception(String.format("Cannot handle '%s'.", item.getClass())); } }