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

private static String getTextValue(Element ele, String tagName) 

Method Source Code

//package com.java2s;
/*/*ww w.  ja  va2  s  .  c  om*/
* Copyright 2012 Periklis G. Liaskovitis
*
* This file is part of component-objects-system.
*
* component-objects-system is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* component-objects-system is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with component-objects-system. If not, see <http://www.gnu.org/licenses/>.
*/

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

public class Main {
    private 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. getTextTrim(Element element)
  3. getTextValue(Element el, 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 ele, String tagName)