Here you can find the source of getXMLElementTextValue(Element element, String tagName)
Parameter | Description |
---|---|
element | , the element to parse from, never <code>null</code> |
tagName | , the name of the tag, never <code>null</code> |
null
if not exists
public static String getXMLElementTextValue(Element element, String tagName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /**//from ww w. j a v a 2 s . co m * Parse the text value of the tag with the specified name. * * @param element * , the element to parse from, never <code>null</code> * @param tagName * , the name of the tag, never <code>null</code> * @return the text value of the tag, <code>null</code> if not exists */ public static String getXMLElementTextValue(Element element, String tagName) { NodeList nl = element.getElementsByTagName(tagName); if (nl != null && nl.getLength() > 0) { Element el = (Element) nl.item(0); return el.getFirstChild().getNodeValue(); } return null; } }