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.*;

public class Main {
    /**
     * Helper Method. Searches through the child nodes of a node and returns the first node with a matching name.
     * Do we need this ?
     * @param element Element
     * @param name String
     * @param caseSensitive boolean
     * @return Node
     */

    public static Node getChildNodeByName(Node element, String name, boolean caseSensitive) {
        NodeList list = element.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            Node node = list.item(i);
            if (caseSensitive) {
                if (node.getNodeName().equals(name))
                    return node;
            } else {
                if (node.getNodeName().equalsIgnoreCase(name))
                    return node;
            }
        }
        return null;
    }
}