Element

Elements are among the most frequent nodes of a document tree.

Elements may have attributes associated with them. Use the attribute related methods of node interface to manipulate the attribute nodes of an element.

Tag Name

tag-name element

The tag-name attribute provides the name of the element. For example in <USERNAME> tag-name has the value "USERNAME".

Get Attribute

get-attribute element name

The get-attribute method retrieves an attribute value by name. The method takes two arguments: An element, and an attribute name. It returns the attribute value as a string.

Get Attribute NS

get-attribute-ns element namespace-uri local-name

Retrieves an attribute value by local name and namespace URI.

Get Attribute Node NS

get-attribute-node-ns element namespace-uri local-name

Retrives an attribute node by local name and namespace URI.

Get Elements By Tag Name

get-elements-by-tag-name element name

The get-elements-by-tag-name method returns a nodelist of all descendant elements with the given tag name. The method takes two arguments: An element, and the name of the tag to match on ("*" matches all tags).

Get Elements By Tag Name NS

get-elements-by-tag-name-ns element namespace-uri local-name

Rreturns a nodelist of all descendant elements with a given local name and namespace URI in the order in which they are found. The wildcard '*' matches all namespaces.

Has Attribute

has-attribute element name

True when an attribute with a given name is specified on this element or has a defaut value.

Has Attribute NS

has-attribute-ns element namespace-uri local-name

True when an attribute with a given local name and namespace is specified on this element or has a defaut value.

Remove Attribute

remove-attribute element name

The remove-attribute method removes an attribute by name. the method takes two arguments: An element, and the name of the attribute to remove.

Remove Attribute NS

remove-attribute-ns element namespace-uri local-name

removes an attribute by local name and namespace URI.

Set Attribute

set-attribute element name value

The set-attribute method adds a new attribute, or changes the value of an existsing attribute. The method takes three arguments: An element, the name of the attribute to create or alter, and the value to set in string form.

Set Attribute NS

set-attribute-ns element namespace-uri qualified-name value

Adds a new attribute, or changes the value of an existing attribute.

Set Attribute Node

set-attribute-node element attribute

The set-attribute-node method adds a new attribute, or replaces an existsing attribute node with the same name. The method takes two arguments: An element, and an attribute node. The method returns a previously existsing node if one is replaced.

Set Attribute Node NS

set-attribute-node-ns element attribute

Adds a new attribute, or replaces an existsing attribute node with the same name.

Remove Attribute Node

remove-attribute-node element old-attribute

The remove-attribute-node method removes the specified attribute. It takes two arguments: An element, and the old attribute node. The method returns the removed attribute node.

Normalize

normalize element

Concatenates all adjacent text nodes in the element. The method takes one argument: The element.