Object (inherits from Node).
Attr has no methods of its own. See also Element, as attr represents an attribute of a markup element.
Note that the DOM does not place Attr nodes within the hierarchy. They are considered mere properties of the associated Element node - their parentNode, previousSibling and nextSibling are null. An Attr's only possible child node types are Text and EntityReference.
Some random XML markup:
<!DOCTYPE doc PUBLIC "-//funnytoes//DTD docdtd XML V1//EN" "/usr/dtd/doc/doc.dtd">
<doc type="doctype">
<docbody docname="first doc" author="funnytoes"/>
<docbody docname="second doc "last""/>
</doc>
The DOM objects here are:
- A Document node, with two (direct) children:
- A DocumentType node, named "doc"
- An Element node, tagName "doc", attributes containing:
- An Attr node, named "type", specified true, having a single child:
- A Text node containing "doctype".
- Other Attr nodes for attributes from the DTD with default values
...and two children:
- An Element node, tagName "docbody", attributes containing:
- An Attr node, named "docname", specified true, having a single child:
- A Text node containing "first doc".
- An Attr node, named "author", specified true, having a single child:
- A Text node containing "funnytoes".
- Other Attr nodes for attributes from the DTD with default values
...and no child nodes.
- An Element node, tagName "docbody", attributes containing:
- An Attr node, named "docname", specified true, having four children:
- A Text node containing "second doc ".
- An EntityReference node for the first """.
- A Text node containing "last".
- An EntityReference node for the second """.
- Other Attr nodes for attributes from the DTD with default values
...and no child nodes.