Java XML Node Text Value getNodeTextValue(Node node)

Here you can find the source of getNodeTextValue(Node node)

Description

get Node Text Value

License

Open Source License

Declaration

private static String getNodeTextValue(Node node) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright ? 2006, 2013 IBM Corporation 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:/*  w w  w .  j  ava  2s  .  c  om*/
 * IBM Corporation - initial API and implementation
 *
 *******************************************************************************/

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static String getNodeTextValue(Node node) {
        String value = "";
        NodeList nodes = node.getChildNodes();
        for (int idx = 0; idx < nodes.getLength(); idx++) {
            node = nodes.item(idx);
            if (node.getNodeType() == Node.TEXT_NODE) {
                value = node.getNodeValue();
                break;
            }
        }
        return value;
    }
}

Related

  1. getNodeTextValue(final Node node)
  2. getNodeTextValue(final Node node)
  3. getNodeTextValue(Node node)
  4. getNodeTextValue(Node node)
  5. getNodeTextValue(Node node)
  6. getNodeTextValue(Node pElement)
  7. getNormalizedText(Node node)
  8. getPlainTextBelow(Node n)
  9. getPropertiesFromXML(Node propNode)