Java XML Node Text Value getString(final Node node, final String default_value)

Here you can find the source of getString(final Node node, final String default_value)

Description

get String

License

Open Source License

Declaration

final public static String getString(final Node node, final String default_value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 Oak Ridge National Laboratory.
 * 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
 ******************************************************************************/

import org.w3c.dom.Node;

public class Main {
    final public static String getString(final Node node, final String default_value) {
        if (node != null) {
            Node text_node = node.getFirstChild();
            if (text_node == null)
                return default_value;
            return text_node.getNodeValue();
        }/*from w w  w. j av a2  s . co m*/
        return default_value;
    }
}

Related

  1. getRawContent(Node n)
  2. getSimpleElementText(final Node node)
  3. getSimpleNodeValue(Node node)
  4. getSingleNodeTextContent(Node node, String path)
  5. getStrElementValue(Node node)
  6. getString(Node node)
  7. getStringValue(NamedNodeMap values, String name)
  8. getStringValue(Node node)
  9. getStringValue(Node node)