Here you can find the source of nodeToDouble(Node node)
Parameter | Description |
---|---|
node | The node to be parsed |
protected static Double nodeToDouble(Node node)
//package com.java2s; /**/* w w w .ja v a 2 s . c o m*/ * Copyright (c) 2006, 2009 Hugo Corbucci and others.<br> * 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<br> * <br> * Contributors:<br> * Mariana V. Bravo - initial API and implementation<br> * Victor D. Lopes, Hugo Corbucci - later contributions<br> * <br> * This file was created on 2006/09/10, 10:04:05, by Victor D. Lopes.<br> * It is part of package br.org.archimedes.io.xml.parsers on the br.org.archimedes.io.xml project.<br> */ import java.text.NumberFormat; import java.text.ParseException; import org.w3c.dom.Node; public class Main { private static NumberFormat nf; /** * Converts a node to a double * * @param node * The node to be parsed * @return The obtained value */ protected static Double nodeToDouble(Node node) { Double returnValue = null; try { String nodeValue = node.getFirstChild().getNodeValue(); nodeValue = nodeValue.trim(); returnValue = nf.parse(nodeValue).doubleValue(); } catch (ParseException e) { // Should never happen e.printStackTrace(); } return returnValue; } }