Here you can find the source of getElementContent(final Element element, final boolean trim)
public static String getElementContent(final Element element, final boolean trim)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.Text; public class Main { public static String getElementContent(final Element element, final boolean trim) { final NodeList nl = element.getChildNodes(); String attributeText = ""; for (int i = 0; i < nl.getLength(); i++) { final Node n = nl.item(i); if (n instanceof Text) { attributeText += ((Text) n).getData(); }/*from www . j ava2 s . co m*/ } if (trim) { attributeText = attributeText.trim(); } return attributeText; } }