Java tutorial
//package com.java2s; /* This file is part of GALE (Generic Adaptation Language and Engine). GALE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GALE 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GALE. If not, see <http://www.gnu.org/licenses/>. */ import org.w3c.dom.Node; public class Main { /** * Returns the value of <code>Node</code>. This is done by assuming that * this node has one child that is a textnode. The value of this textnode is * returned. * * @param node * The node that has to be examined. * @return The value of the node. */ public static String nodeValue(Node node) { if (node == null) return null; Node child = node.getFirstChild(); if (child == null) return null; return (child.toString().equals("") ? null : child.toString()); } }