code: public static Map<QName, String> getAttributes(Node n) {
          Map<QName, String> map = new LinkedHashMap<QName, String>();
          NamedNodeMap m = n.getAttributes();
          if (m != null) {
              final int len = m.getLength();
              for (int i = 0; i < len; i++) {
                  Attr a = (Attr) m.item(i);
                  map.put(getQName(a), a.getValue());
              }
          }
          return map;
      }
docs: Obtains an element's attributes as Map.