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 java.util.Map;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static void getNamespaces(Node node, Map<String, String> list) {
        NamedNodeMap atts = node.getAttributes();
        for (int i = 0; i < atts.getLength(); i++) {
            Node n = atts.item(i);
            if ("xmlns".equals(n.getNodeName())) {
                list.put(n.getNodeName(), n.getNodeValue());
            } else {
                if (n.getNodeName().startsWith("xmlns:")) {
                    list.put(n.getNodeName().substring(6), n.getNodeValue());
                }
            }
        }
    }
}