Java XML Attribute from Element getTagAttributes(Element element)

Here you can find the source of getTagAttributes(Element element)

Description

get Tag Attributes

License

LGPL

Declaration

private static Map<String, String> getTagAttributes(Element element) 

Method Source Code

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

import java.util.LinkedHashMap;

import java.util.Map;

import org.w3c.dom.Attr;

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

public class Main {
    private static Map<String, String> getTagAttributes(Element element) {
        Map<String, String> attributes = new LinkedHashMap<String, String>();
        NamedNodeMap sourceAttributes = element.getAttributes();

        for (int i = 0; i < sourceAttributes.getLength(); ++i) {
            Attr attribute = (Attr) sourceAttributes.item(i);
            attributes.put(attribute.getName(), attribute.getValue());
        }/*w w  w .  j  av a 2s  .c o m*/

        return attributes;
    }
}

Related

  1. getStringAttributeValue(final Element element, final String attributeName)
  2. getStringAttributeValue(final Element element, final String attributeName)
  3. getTagAttribute(String sTag, String sAtt, Element eElement)
  4. getTagAttribute(XMLStreamReader xmler, String attribute, String defaultValue)
  5. getTagAttributeRecursive(String sTag, String sAtt, Element eElement)
  6. getThisClassTypeAttr(Element methodNode)
  7. getTrimedAttribute(Element elem, String attr_name)
  8. getValue(final Element elem, final String attrName)
  9. getValueAttribute(final Node aNode)