Java XML Attribute Get getAttributes(Element el)

Here you can find the source of getAttributes(Element el)

Description

get attribute map from the element

License

Open Source License

Parameter

Parameter Description
el - element

Return

mapping of attributes

Declaration

public static Map<String, String> getAttributes(Element el) 

Method Source Code

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

import java.util.LinkedHashMap;

import java.util.Map;

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

public class Main {
    /**//from   w w w.java  2  s  .c o  m
     * get attribute map from the element
     * @param el - element
     * @return mapping of attributes
     */
    public static Map<String, String> getAttributes(Element el) {
        Map<String, String> list = new LinkedHashMap<String, String>();
        NamedNodeMap map = el.getAttributes();
        for (int i = 0; i < map.getLength(); i++) {
            list.put(map.item(i).getNodeName(), map.item(i).getNodeValue());
        }
        return list;
    }
}

Related

  1. getAttributeNSOrNull(Element e, String name, String nsURI)
  2. getAttributeNSOrNull(Element e, String name, String nsURI)
  3. getAttributeOrNull(String attribute, Element element)
  4. getAttributePropertyFromElement(final Element element, final String attribute)
  5. getAttributes(Element el)
  6. getAttributes(Element el)
  7. getAttributes(Element element)
  8. getAttributes(Element element)
  9. getAttributes(Element root, String elementName, String[] wantedAttributes)