Easy Tutorial
❮ Met Comment Substringdata Prop Comment Length ❯

XML DOM attributes Attribute



Definition and Usage

The attributes attribute returns a NamedNodeMap containing the attributes of the selected node.

If the selected node is not an element, this attribute returns NULL.

Syntax


Tips and Notes

Tip: This attribute is only used for element nodes.


Example 1

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and gets the number of attributes of the first <title> element in "books.xml":

Example

The above code will output:


Example 2

The following code snippet uses loadXMLDoc() to load "books.xml" into xmlDoc and gets the value of the "category" attribute in the first <book> element:

Example

The above code will output:


❮ Met Comment Substringdata Prop Comment Length ❯