find XML Sub Node - Java XML

Java examples for XML:DOM Node

Description

find XML Sub Node

Demo Code


//package com.java2s;

import org.w3c.dom.Node;

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

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

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

Related Tutorials