Java tutorial
//package com.java2s; import org.w3c.dom.*; import java.util.*; public class Main { /** * Method get all attributes in a xml element. * @param el xml element on input. * @return array list of attributes. */ public static List<Attr> getAllAttributes(Element el) { List<Attr> listAttr = new ArrayList<>(); NamedNodeMap attributes = el.getAttributes();//get map containing the attributes of this node int numAttrs = attributes.getLength(); //get the number of nodes in this map for (int i = 0; i < numAttrs; i++) { Attr attr = (Attr) attributes.item(i); listAttr.add(attr); } return listAttr; } }