Here you can find the source of getTextContent(Element e)
Parameter | Description |
---|---|
e | a parameter |
public static String getTextContent(Element e)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**/*from www .j a v a 2 s . c om*/ * * @param e * @return */ public static String getTextContent(Element e) { String ret = null; boolean found = false; StringBuffer buffer = new StringBuffer(); NodeList childList = e.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node child = childList.item(i); if (child.getNodeType() != Node.TEXT_NODE) continue; // skip non-text nodes buffer.append(child.getNodeValue()); found = true; } if (found) { ret = buffer.toString(); } return ret; } }