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 element
The tag-name attribute provides the name of the element. For example in <USERNAME> tag-name has the value "USERNAME".
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 element namespace-uri local-name
Retrieves an attribute value by local name and namespace URI.
get-attribute-node-ns element namespace-uri local-name
Retrives an attribute node by local name and namespace URI.
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 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 element name
True when an attribute with a given name is specified on this element or has a defaut value.
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 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 element namespace-uri local-name
removes an attribute by local name and namespace URI.
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 element namespace-uri qualified-name value
Adds a new attribute, or changes the value of an existing attribute.
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 element attribute
Adds a new attribute, or replaces an existsing attribute node with the same name.
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 element
Concatenates all adjacent text nodes in the element. The method takes one argument: The element.