Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    /***********************************************************************/
    private static Node traverseToInnerTag(String tag, Node node) {
        String name = node.getNodeName();
        if (name.equals(tag)) {
            return node;
        } else {
            NodeList childNodes = node.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                Node child = traverseToInnerTag(tag, childNodes.item(i));
                if (child != null) {
                    return child;
                }
            }
        }
        return null;
    }
}