Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.Document;

import org.w3c.dom.NodeList;

public class Main {
    /**
     * Check to see if a node exists in the document with the node name passed in.
     * 
     * @param doc
     * @param nodeName
     * @return true if it exists
     */
    public static boolean getNodeExists(Document doc, String nodeName) {
        if (doc == null || nodeName == null)
            return false;
        NodeList nodes = doc.getElementsByTagName(nodeName);
        if (nodes == null)
            return false;
        return nodes.getLength() > 0;
    }
}