Java XML Attribute Get getAttributes(Node node)

Here you can find the source of getAttributes(Node node)

Description

get Attributes

License

LGPL

Declaration

public static Map<String, String> getAttributes(Node node) 

Method Source Code


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

import org.w3c.dom.Attr;

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

import java.util.*;

public class Main {
    public static Map<String, String> getAttributes(Node node) {
        NamedNodeMap attributeMap = node.getAttributes();
        HashMap<String, String> attributes = new HashMap<String, String>(attributeMap.getLength());
        for (int i = 0; i < attributeMap.getLength(); i++) {
            Node attr = attributeMap.item(i);
            if (attr instanceof Attr) {
                attributes.put(((Attr) attr).getName(), ((Attr) attr).getValue());
            }/*  w w w .j a v  a 2  s.  c o m*/
        }
        return attributes;
    }
}

Related

  1. getAttributes(Node n)
  2. getAttributes(Node node)
  3. getAttributes(Node node)
  4. getAttributes(Node node)
  5. getAttributes(Node node)
  6. getAttributes(Node node)
  7. getAttributes(Node node)
  8. getAttributes(Node node)
  9. getAttributes(Node node)