Listing All the Attributes of a DOM Element

// Get all the attributes of an element in a map NamedNodeMap attrs = element.getAttributes(); // Get number of attributes in the element int numAttrs = attrs.getLength(); // Process each attribute for (int i=0; i<numAttrs; i++) { Attr attr = (Attr)attrs.item(i); // Get attribute name and value String attrName = attr.getNodeName(); String attrValue = attr.getNodeValue(); }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.