Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License"); you may

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

public class Main {
    public static String getTagValue(String sTag, Element eElement) {
        if (eElement.getElementsByTagName(sTag) == null)
            return "";
        if (eElement.getElementsByTagName(sTag).getLength() == 0)
            return "";
        NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
        if (nlList == null || nlList.getLength() == 0)
            return "";
        Node nValue = (Node) nlList.item(0);
        return nValue.getNodeValue();
    }
}