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.NamedNodeMap;
import org.w3c.dom.Node;

public class Main {
    public static HashMap<String, String> getNodeAttributesMap(Node node) {
        HashMap<String, String> map = new HashMap<String, String>();

        NamedNodeMap namedNodeMap = node.getAttributes();
        for (int i = 0; i < namedNodeMap.getLength(); i++) {
            Node attribute = namedNodeMap.item(i);
            map.put(attribute.getNodeName(), attribute.getNodeValue());
        }

        return map;
    }
}