Here you can find the source of getTextContent(Element e, String name)
static public String getTextContent(Element e, String name)
//package com.java2s; /******************************************************************************* * Copyright (c) 2006 Vladimir Silva and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j a v a 2 s .com * Vladimir Silva - initial API and implementation *******************************************************************************/ import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { static public String getTextContent(Element e, String name) { NodeList nl = e.getElementsByTagName(name); try { return (nl != null && nl.getLength() > 0) ? nl.item(0).getTextContent().trim() : null; } catch (NullPointerException ex) { return null; } } }