Here you can find the source of getTextFromTag(Element current, String tag)
Parameter | Description |
---|---|
current | the current element |
tag | the tag name |
private static String getTextFromTag(Element current, String tag)
//package com.java2s; // under the terms of the GNU Lesser General Public License as published by import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**/*ww w . ja va 2 s . com*/ * Return the inner text from the given tag * * @param current * the current element * @param tag * the tag name * @return the text inside the tag, or "" */ private static String getTextFromTag(Element current, String tag) { if (current == null) return ""; String result = ""; NodeList nodes = current.getElementsByTagName(tag); if (nodes.getLength() > 0) result = ((Element) nodes.item(0)).getTextContent(); return result; } }