get XML Node Long Value - Android XML

Android examples for XML:XML Node

Description

get XML Node Long Value

Demo Code


//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static long getNodeLongValue(Node node, long defaultValue) {
        long value = defaultValue;

        try {//from   w  ww  . j a va  2  s . c o m
            if (node.getFirstChild() != null)
                value = Long.parseLong(node.getFirstChild().getNodeValue());
        } catch (Exception e) {
            value = defaultValue;
        }

        return value;
    }

    public static String getNodeValue(Node node) {
        String value = "";

        try {
            if (node.getFirstChild() != null)
                value = node.getFirstChild().getNodeValue();
        } catch (Exception e) {
            value = null;
        }

        return value;
    }
}

Related Tutorials