Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.HashMap;

import org.w3c.dom.Element;

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

public class Main {
    public static HashMap<String, Node> getNodes(Node p_node) throws Exception {

        NodeList l_list = null;
        Node l_node = null;
        HashMap<String, Node> l_a = null;

        l_list = p_node.getChildNodes();
        if (l_list == null) {
            throw new Exception("XSD001: Unsupported / Invalid Element Type.");
        }
        l_a = new HashMap<String, Node>();
        for (int l_i = 0; l_i < l_list.getLength(); l_i++) {
            l_node = l_list.item(l_i);
            if (l_node.getNodeType() == Element.ELEMENT_NODE) {
                l_a.put(l_node.getNodeName(), l_node);
            }
        }

        return l_a;
    }
}