attributes: NamedNodeMap
Has meaning only for Element
objects. It provides access to a
list of Attr
objects in a
NamedNodeMap
. For all other
object types, it returns null
.
// List the attributes of an Element node NamedNodeMap nnm = doc.getDocumentElement( ).getAttributes( ); if (nnm != null) { for (int i = 0; i < nnm.getLength( ); i++) { // print the attribute and value System.out.println(nnm.item(i).getNodeName( ) + " = \"" + nnm.item(i).getNodeValue( ) + "\""); } }