Java XML Element Get Value getTextValue(Element ele, String tagName)

Here you can find the source of getTextValue(Element ele, String tagName)

Description

get Text Value

License

Open Source License

Declaration

public static String getTextValue(Element ele, String tagName) 

Method Source Code

//package com.java2s;
/****************************************************
Statistics Online Computational Resource (SOCR)
http://www.StatisticsResource.org//from w w w.  j  a  v  a 2s  . com
     
All SOCR programs, materials, tools and resources are developed by and freely disseminated to the entire community.
Users may revise, extend, redistribute, modify under the terms of the Lesser GNU General Public License
as published by the Open Source Initiative http://opensource.org/licenses/. All efforts should be made to develop and distribute
factually correct, useful, portable and extensible resource all available in all digital formats for free over the Internet.
     
SOCR resources are distributed in the hope that they will be useful, but without
any warranty; without any explicit, implicit or implied warranty for merchantability or
fitness for a particular purpose. See the GNU Lesser General Public License for
more details see http://opensource.org/licenses/lgpl-license.php.
     
http://www.SOCR.ucla.edu
http://wiki.stat.ucla.edu/socr
 It s Online, Therefore, It Exists! 
****************************************************/

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Main {
    public static String getTextValue(Element ele, String tagName) {
        String textVal = null;
        NodeList nl = ele.getElementsByTagName(tagName);
        if (nl != null && nl.getLength() > 0) {
            Element el = (Element) nl.item(0);
            textVal = el.getFirstChild().getNodeValue();
        }

        return textVal;
    }
}

Related

  1. getTextTrim(Element element)
  2. getTextValue(Element el, String tagName)
  3. getTextValue(Element ele, String tagName)
  4. getTextValue(Element ele, String tagName)
  5. getTextValue(Element ele, String tagName)
  6. getTextValue(Element ele, String tagName)
  7. getTextValue(Element ele, String tagName)
  8. getTextValue(Element ele, String tagName)
  9. getTextValue(Element element)