Java XML Attribute Load loadAttributes(Element e)

Here you can find the source of loadAttributes(Element e)

Description

load Attributes

License

Apache License

Declaration

public static Map<String, Object> loadAttributes(Element e) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;
import java.util.Map;

import org.w3c.dom.Attr;

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

public class Main {
    public static Map<String, Object> loadAttributes(Element e) {
        Map<String, Object> map = new HashMap<String, Object>();
        NamedNodeMap nm = e.getAttributes();
        for (int j = 0; j < nm.getLength(); j++) {
            Node n = nm.item(j);// w w w  .  ja  v a2 s  . co  m
            if (n instanceof Attr) {
                Attr attr = (Attr) n;
                map.put(attr.getName(), attr.getNodeValue());
            }
        }
        return map;
    }
}

Related

  1. getAllAttributesAsMap(@Nullable final Element aSrcNode)
  2. getAllAttrs(Element parent, String name, List lst)
  3. getAllAttrValueByName(Node item, String name)
  4. getAllElementAttributes(Element element)
  5. getAllElementsWithAttrId(final Element element, final String namespace)