Here you can find the source of getTextValue(Element element)
Parameter | Description |
---|---|
element | Element whose text element we want |
public static String getTextValue(Element element)
//package com.java2s; //License from project: Apache License import org.w3c.dom.NodeList; import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** Get the value of the first text child of an element. /*from w w w . java2s . co m*/ @param element Element whose text element we want @return String value or null. */ public static String getTextValue(Element element) { NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { Node node = childs.item(i); if (Node.TEXT_NODE == node.getNodeType()) { return node.getNodeValue(); } } return null; } }