Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Element;

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

public class Main {
    public static Node getTag(Element root, String tagName) {
        NodeList list = root.getElementsByTagName(tagName);
        for (int loop = 0; loop < list.getLength(); loop++) {
            Node node = list.item(loop);
            System.out.println("nodeName : " + node.getNodeName() + ":::::" + node.getNodeType());
            if (node.getNodeName().equals(tagName)) {
                return node;
            }
        }
        return null;
    }
}