Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

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

public class Main {
    public static String getTagValue(Node node, String name) {

        if (node.getNodeType() == Node.ELEMENT_NODE) {

            Element el = (Element) node;
            NodeList nodeList = el.getElementsByTagName(name);
            if (nodeList.getLength() > 0) {
                el = (Element) nodeList.item(0);
                nodeList = el.getChildNodes();

                if (nodeList.getLength() > 0) {
                    return ((Node) nodeList.item(0)).getNodeValue();
                }
            }

        }
        return "";
    }
}