Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.LinkedHashMap; import java.util.Map; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; public class Main { /** * Converts {@link NamedNodeMap} to a {@link LinkedHashMap}<String,String>. * @param _nodeMap node map * @return {@link LinkedHashMap}, maybe empty but never null */ public static Map<String, String> convertToAttributeMap(NamedNodeMap _nodeMap) { Map<String, String> map = new LinkedHashMap<>(); for (int i = 0; i < _nodeMap.getLength(); i++) { Node node = _nodeMap.item(i); map.put(node.getNodeName(), node.getNodeValue()); } return map; } }