The Attr Interface
Probably 90 percent of the time, everything you need to do with attributes can be done purely through the various attribute methods of the Element interface. However, occasionally the Attr interface comes in handy. An Attr object represents an attribute, whether explicitly included in the document or present by default from the schema.
Example 11.15 summarizes the Attr interface. In addition to methods inherited from the Node superinterface, Attr includes methods to do the following:
Get the full name of the attribute (including a prefix, if any)
Determine whether the attribute was specified in the document or merely appears by default from the DTD or schema
Get the element that contains this attribute
Get the value of the attribute. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access