Here you can find the source of getNodeContents(Node parentNode)
public static String getNodeContents(Node parentNode)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static String getNodeContents(Node parentNode) { StringBuilder sb = new StringBuilder(); NodeList childNodes = parentNode.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); String nodeValue = node.getNodeValue(); if (nodeValue != null) sb.append(nodeValue);//from www.ja v a 2 s .c om } return sb.toString(); } }