# Titanium.XML.Element
Represents an element in a DOM document, a Titanium.XML.Node defined by a start-tag and end-tag (or an empty tag). Elements may have Titanium.XML.Attr associated with them. Implements the DOM Level 2 API on Android and iOS with some non-standard extensions.
# Properties
# text READONLYDEPRECATED
DEPRECATED SINCE 2.0.0
Use textContent instead.
Content (value) of all text nodes within this node.
# textContent READONLY
Content (value) of all text nodes within this node.
On Android, textContent
is supported on Titanium.XML.Element and
Titanium.XML.Text nodes only.
# Methods
# getAttribute
Retrieves an attribute value by name, returning it as a string.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the attribute |
Returns
The Titanium.XML.Attr value as a string, or empty string if the attribute has no specified or default value.
- Type
- String
# getAttributeNode
Retrieves an attribute value by name, returning it as a Titanium.XML.Attr object.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the attribute |
Returns
The Titanium.XML.Attr value, or null if there is no such attribute.
- Type
- Titanium.XML.Attr
# getAttributeNodeNS
Retrieves an attribute value by local name and namespace URI, returning it as a Titanium.XML.Attr object.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the attribute to retrieve. |
localName | String | The local name of the attribute to retrieve. |
Returns
The Titanium.XML.Attr value, or null if there is no such attribute.
- Type
- Titanium.XML.Attr
# getAttributeNS
Retrieves an attribute value by local name and namespace URI, returning it as a string.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the attribute to retrieve. |
localName | String | The local name of the attribute to retrieve. |
Returns
The Titanium.XML.Attr value as a string, or empty string if the attribute has no specified or default value.
- Type
- String
# getElementsByTagName
Retrieves a Titanium.XML.NodeList of all descendant elements with a given tag name, in preorder traversal.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the element. The value |
Returns
# getElementsByTagNameNS
Retrieves a Titanium.XML.NodeList of all descendant elements with a given local name and namespace URI, in preorder traversal.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the element. The value |
localName | String | The local name of the element. The value |
Returns
# hasAttribute
Determines whether or not an attribute with the given name is available in the element, or has a default value.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the attribute to search for. |
Returns
- Type
- Boolean
# hasAttributeNS
Determines whether or not an attribute with the given name is available in the element, or has a default value.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the attribute to search for. |
localName | String | The local name of the attribute to search for. |
Returns
- Type
- Boolean
# removeAttribute
Removes an attribute by name. If the attribute has a default value, it is immediately replaced with this default, including namespace URI and local name. Throws an exception if the element is read-only.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the attribute to remove. |
Returns
- Type
- void
# removeAttributeNode
Removes the specified attribute node. If the removed attribute has a default value, it is replaced immediately, with the same namespace and local name as the removed attribute, if applicable. Throws an exception if the element is read-only, or the attribute is not an attribute of the element.
Parameters
Name | Type | Description |
---|---|---|
oldAttr | Titanium.XML.Attr | The attribute to remove. |
Returns
- Type
- void
# removeAttributeNS
Removes an attribute by local name and namespace URI. If the attribute has a default value, it is immediately replaced with this default, including namespace URI and local name. Throws an exception if the element is read-only.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the attribute to remove. |
localName | String | The local name of the attribute to remove. |
Returns
- Type
- void
# setAttribute
Adds a new attribute. Any attribute with the same name is replaced. Throws an exception if the element is read-only, or if the name contains an illegal character.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name of the attribute. |
value | String | The value of the attribute. This is value is not parsed as part of the assignment. Any markup is treated as literal text, and needs to be escaped. |
Returns
- Type
- void
# setAttributeNode
Adds a new attribute. Any attribute with the same nodeName
as the argument is replaced. Throws an exception if the element is read-only, if newAttr
is from a different document, or if newAttr
is already an attribute of another element.
Parameters
Name | Type | Description |
---|---|---|
newAttr | Titanium.XML.Attr | The attribute node to add to the element. |
Returns
The attribute that was replaced, or null
otherwise.
- Type
- Titanium.XML.Attr
# setAttributeNodeNS
Adds a new attribute. Any attribute with the same local name and namespace URI is replaced. Throws an exception if the element is read-only, if newAttr
is from a different document, or if newAttr
is already an attribute of another element.
Parameters
Name | Type | Description |
---|---|---|
newAttr | Titanium.XML.Attr | The attribute node to add to the element. |
Returns
The attribute that was replaced, or null
otherwise.
- Type
- Titanium.XML.Attr
# setAttributeNS
Adds a new attribute. Any attribute with the same local name and namespace URI is present on the element is replaced, with its prefix changed to that of the qualifiedName
parameter. Throws an exception if the element is read-only, if the name contains an illegal character, or if the qualified name contains an error.
Parameters
Name | Type | Description |
---|---|---|
namespaceURI | String | The namespace URI of the attribute. |
qualifiedName | String | |
value | String | The value of the attribute. This is value is not parsed as part of the assignment. Any markup is treated as literal text, and needs to be escaped. |
Returns
- Type
- void