Here you can find the source of getTextValue(Element ele, String tagName)
private static String getTextValue(Element ele, String tagName)
//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; } }