Skip to content
Titanium SDK
Version13.0.1

You are reading 13.0.1. See this page in 13.4.1.

Titanium.XML.Element

proxyAndroidiPhoneiPadmacOSsince Android 0.9, iPhone 0.9, iPad 0.9, macOS 9.2.0

Extends Titanium.XML.NodeTitanium.Proxy

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 attributes associated with them. Implements the DOM Level 2 API on Android and iOS with some non-standard extensions.

Properties 32

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

nodeType

Numberread-only

Inherited from Titanium.XML.Node

This node's type. One of ELEMENT_NODE, ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, ENTITY_REFERENCE_NODE, ENTITY_NODE, PROCESSING_INSTRUCTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, DOCUMENT_FRAGMENT_NODE, NOTATION_NODE.

tagName

Stringread-only

The name of the element, as defined by its tag.

textContent

Stringread-only

Content (value) of all text nodes within this node.

On Android, textContent is supported on Element and Text nodes only.

Methods 28

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Retrieves an attribute value by name, returning it as a string.

Parameters
ParametersTypeDescription
nameString

The name of the attribute

Returns String

The Titanium.XML.Attr value as a string, or empty string if the attribute has no specified or default value.

Retrieves an attribute value by local name and namespace URI, returning it as a Titanium.XML.Attr object.

Parameters
ParametersTypeDescription
namespaceURIString

The namespace URI of the attribute to retrieve.

localNameString

The local name of the attribute to retrieve.

Returns Titanium.XML.Attr

The Titanium.XML.Attr value, or null if there is no such attribute.

Retrieves an attribute value by local name and namespace URI, returning it as a string.

Parameters
ParametersTypeDescription
namespaceURIString

The namespace URI of the attribute to retrieve.

localNameString

The local name of the attribute to retrieve.

Returns String

The Titanium.XML.Attr value as a string, or empty string if the attribute has no specified or default value.

Retrieves a Titanium.XML.NodeList of all descendant elements with a given local name and namespace URI, in preorder traversal.

Parameters
ParametersTypeDescription
namespaceURIString

The namespace URI of the element. The value * matches all namespaces.

localNameString

The local name of the element. The value * matches all local names.

Determines whether or not an attribute with the given name is available in the element, or has a default value.

Parameters
ParametersTypeDescription
nameString

The name of the attribute to search for.

Returns Boolean

Determines whether or not an attribute with the given name is available in the element, or has a default value.

Parameters
ParametersTypeDescription
namespaceURIString

The namespace URI of the attribute to search for.

localNameString

The local name of the attribute to search for.

Returns Boolean

Inherited from Titanium.XML.Node

Returns true if this node has attributes.

Returns Boolean

True if this node has attributes, false if it does not.

Inherited from Titanium.XML.Node

Returns true if this node has child nodes.

Returns Boolean

True if this node has children, false if it does not.

Inherited from Titanium.XML.Node

Tests whether the DOM implementation supports a specific feature.

Parameters
ParametersTypeDescription
featureString

Name of the feature.

versionString

Version number of the feature.

Returns Boolean

True if the feature is supported, false if it is not.

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
ParametersTypeDescription
nameString

The name of the attribute to remove.

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
ParametersTypeDescription
oldAttrTitanium.XML.Attr

The attribute to remove.

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
ParametersTypeDescription
namespaceURIString

The namespace URI of the attribute to remove.

localNameString

The local name of the attribute to remove.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

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
ParametersTypeDescription
nameString

The name of the attribute.

valueString

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.

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
ParametersTypeDescription
newAttrTitanium.XML.Attr

The attribute node to add to the element.

Returns Titanium.XML.Attr

The attribute that was replaced, or null otherwise.

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
ParametersTypeDescription
newAttrTitanium.XML.Attr

The attribute node to add to the element.

Returns Titanium.XML.Attr

The attribute that was replaced, or null otherwise.

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
ParametersTypeDescription
namespaceURIString

The namespace URI of the attribute.

qualifiedNameString

The qualified name of the attribute. If it is malformed, has a prefix and namespaceURI is null, or if the prefix is xml or xmlns but does not correspond to a property defined in the XML or XMLNS specifications, then it contains an error.

valueString

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.