
- XML DOM Basics
- XML DOM - Home
- XML DOM - Overview
- XML DOM - Model
- XML DOM - Nodes
- XML DOM - Node Tree
- XML DOM - Methods
- XML DOM - Loading
- XML DOM - Traversing
- XML DOM - Navigation
- XML DOM - Accessing
- XML DOM Operations
- XML DOM - Get Node
- XML DOM - Set Node
- XML DOM - Create Node
- XML DOM - Add Node
- XML DOM - Replace Node
- XML DOM - Remove Node
- XML DOM - Clone Node
- XML DOM Objects
- DOM - Node Object
- DOM - NodeList Object
- DOM - NamedNodeMap Object
- DOM - DOMImplementation
- DOM - DocumentType Object
- DOM - ProcessingInstruction
- DOM - Entity Object
- DOM - EntityReference Object
- DOM - Notation Object
- DOM - Element Object
- DOM - Attribute Object
- DOM - CDATASection Object
- DOM - Comment Object
- DOM - XMLHttpRequest Object
- DOM - DOMException Object
- XML DOM Useful Resources
- XML DOM - Quick Guide
- XML DOM - Useful Resources
- XML DOM - Discussion
DOM - Element Object
The XML elements can be defined as building blocks of XML. Elements can behave as containers to hold text, elements, attributes, media objects or all of these. Whenever parser parses an XML document against the well-formedness, parser navigates through an element node. An element node contains the text within it which is called as the text node.
Element object inherits the properties and the methods of the Node object as element object is also considered as a Node. Other than the node object properties and methods it has the following properties and methods.
Properties
The following table lists the attributes of the Element object −
Attribute | Type | Description |
---|---|---|
tagName | DOMString | It gives the name of the tag for the specified element. |
schemaTypeInfo | TypeInfo | It represents the type information associated with this element. This has been removed. Refer specs. |
Methods
Below table lists the Element Object methods −
Methods | Type | Description |
---|---|---|
getAttribute() | DOMString | Retrieves the value of the attribute if exists for the specified element. |
getAttributeNS() | DOMString | Retrieves an attribute value by local name and namespace URI. |
getAttributeNode() | Attr | Retrieves the name of the attribute node from the current element. |
getAttributeNodeNS() | Attr | Retrieves an Attr node by local name and namespace URI. |
getElementsByTagName() | NodeList | Returns a NodeList of all descendant Elements with a given tag name, in document order. |
getElementsByTagNameNS() | NodeList | Returns a NodeList of all the descendant Elements with a given local name and namespace URI in document order. |
hasAttribute() | boolean | Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. |
hasAttributeNS() | boolean | Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. |
removeAttribute() | No Return Value | Removes an attribute by name. |
removeAttributeNS | No Return Value | Removes an attribute by local name and namespace URI. |
removeAttributeNode() | Attr | Specified attribute node is removed from the element. |
setAttribute() | No Return Value | Sets a new attribute value to the existing element. |
setAttributeNS() | No Return Value | Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. |
setAttributeNode() | Attr | Sets a new attribute node to the existing element. |
setAttributeNodeNS | Attr | Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one. |
setIdAttribute | No Return Value | If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This has been removed. Refer specs. |
setIdAttributeNS | No Return Value | If the parameter isId is true, this method declares the specified attribute to be a user-determined ID attribute. This has been removed. Refer specs. |
Advertisements