Java XML Node Read readDouble(Node node)

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

Description

Returns the double value represented by the contents of the given node.

License

Common Public License

Parameter

Parameter Description
node Node The given node.

Return

double Its double value.

Declaration

static public double readDouble(Node node) 

Method Source Code

//package com.java2s;
/***********************************************************
 *      This software is part of the ProM package          *
 *             http://www.processmining.org/               *
 *                                                         *
 *            Copyright (c) 2003-2006 TU/e Eindhoven       *
 *                and is licensed under the                *
 *            Common Public License, Version 1.0           *
 *        by Eindhoven University of Technology            *
 *           Department of Information Systems             *
 *                 http://is.tm.tue.nl                     *
 *                                                         *
 **********************************************************/

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

public class Main {
    /**//  w w w.  ja va2s .  c  o m
     * Returns the double value represented by the contents of the given node.
     * @param node Node The given node.
     * @return double Its double value.
     */
    static public double readDouble(Node node) {
        return Double.parseDouble(readString(node));
    }

    /**
     * Returns the contents of the given node.
     * @param node Node The fiven node.
     * @return String Its contents.
     */
    static public String readString(Node node) {
        NodeList nodes = node.getChildNodes();
        String value = "";
        for (int i = 0; i < nodes.getLength(); i++) {
            value += nodes.item(i).getTextContent();
        }
        return value;
    }
}

Related

  1. readNodeElementsToMap(final Node sourceNode)
  2. readText(Node element)