Here you can find the source of getStringValue(final Element element)
Parameter | Description |
---|---|
element | element to get string value for |
public static String getStringValue(final Element element)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; public class Main { /**//from w ww . j a va2 s . c om * Get element node string value. * * @param element element to get string value for * @return concatenated text node descendant values */ public static String getStringValue(final Element element) { final StringBuilder buf = new StringBuilder(); final NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node n = children.item(i); switch (n.getNodeType()) { case Node.TEXT_NODE: buf.append(n.getNodeValue()); break; case Node.ELEMENT_NODE: buf.append(getStringValue((Element) n)); break; } } return buf.toString(); } }