Here you can find the source of getContent(Element element)
element
.
public static String getContent(Element element)
//package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/* w w w . j ava2 s. c o m*/ * This method will return the content of this particular <code>element</code>. * For example, * * <pre> * <result>something_1</result> * </pre> * When the {@link org.w3c.dom.Element} <code><result></code> is passed in as * argument (<code>element</code> to this method, it returns the content of it, * namely, <code>something_1</code> in the example above. * * @return */ public static String getContent(Element element) { StringBuffer paramValue = new StringBuffer(); NodeList childNodes = element.getChildNodes(); for (int j = 0; j < childNodes.getLength(); j++) { Node currentNode = childNodes.item(j); if (currentNode != null && currentNode.getNodeType() == Node.TEXT_NODE) { String val = currentNode.getNodeValue(); if (val != null) { paramValue.append(val.trim()); } } } String val = paramValue.toString().trim(); return val; } }