Here you can find the source of getAttributes(Node node)
Parameter | Description |
---|---|
node | Node to get attributes from |
public static Map<String, String> getAttributes(Node node)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Attr; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import java.util.*; public class Main { /**/*w w w . j a va2 s . c o m*/ * Creates a map from the attributes of a Node * * @param node Node to get attributes from * @return Map of attributes to values */ 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()); } } return attributes; } }