Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.HashMap;

import java.util.Map;

import org.w3c.dom.Attr;

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

public class Main {
    public static Map<String, String> getMapOfAttributes(Node elem) {
        Map<String, String> attrs = new HashMap<String, String>();
        NamedNodeMap m = elem.getAttributes();
        if (m != null) {
            for (int i = 0; i < m.getLength(); ++i) {
                Attr a = (Attr) m.item(i);
                attrs.put(a.getName(), a.getValue());
            }
        }
        return attrs;
    }
}