read XML Sub Node Long Value - Java XML

Java examples for XML:DOM Node Value

Description

read XML Sub Node Long Value

Demo Code


//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static long readSubNodeLongValue(Node n, String name, long dflt) {
        if (name == null)
            return dflt;

        for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
            if (name.equalsIgnoreCase(d.getNodeName()))
                return Long.parseLong(d.getNodeValue());

        return dflt;
    }/*ww w  .  j a va 2 s .co  m*/
}

Related Tutorials