read Sub XML Node Value - Java XML

Java examples for XML:DOM Node Value

Description

read Sub XML Node Value

Demo Code


//package com.java2s;

import org.w3c.dom.Node;

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

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

        return dflt;
    }//from ww  w.  j a  v a  2 s. c  o  m
}

Related Tutorials