Elements

Nodes that represent elements are often the most common type of node to be found in a document tree structure. The DOM standard includes an Element interface that extends the Node interface to add element-specific functionality. Most of these methods are used to manage attributes, but the first three are more generalized in nature:

String   getTagName();
NodeList getElementsByTagName( String name );
void     normalize();

String   getAttribute( String name );
void     setAttribute( String name, String value )
                                  throws DOMException;
void     removeAttribute( String name )
                                  throws DOMException;

Attr     getAttributeNode( String name );
void     setAttributeNode( Attr newAttr )
                                  throws DOMException;
void     removeAttributeNode( Attr OldAttr )
                                  throws DOMException;

Get XML Companion, The, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.