Element — Inherits Node
The Element interface represents a markup element. In
addition to its Node
-like
methods, it supports access methods to get at contained
attributes.
tagName
The name of the element type. In <stag drums="dale">
, a string
with the value stag
is
returned.
getAttribute(
name
)
This method returns an attribute’s value. This method
bypasses retrieving the Attr
object directly and using its
accessor methods. In some cases, using the Attr
node directly may be more
appropriate, but the convenience methods on the element node
usually suffice.
getAttributeNS(
namespaceURI, localName
)
Similar to getAttribute
, but selects the return
attribute based on namespace as well as name.
getAttributeNode(
name
)
This method returns the actual Attr
object instead of its character
value, as is the case with getAttribute
. Returns None
if no such attribute is
found.
getAttributeNodeNS(
namespaceURI, localName
)
Returns an Attr
node
that matches both the name and namespace URI specified.
Returns None
if no such
attribute is found.
getElementsByTagName(
tagName
)
This method returns a NodeList
of descendant Element
nodes that share the same
element type name. The special value *
matches all tags.
getElementsByTagNameNS(
namespaceURI, localName
)
Returns a NodeList
of
all descendant elements who match both the name and namespace
URI supplied. The value *
in either field matches all namespaces URIs or all local
names; using *
for both
fields matches all elements in the tree rooted at this
node.
hasAttribute(
name
)
This Boolean method returns true
when an attribute with a given
name
is in the element or has a
default value in the DTD.
hasAttributeNS(
namespaceURI, localName
)
This Boolean method returns true
when an attribute of a specific
name and namespace exists within the element or has a default
value stated in the DTD.
removeAttribute(
name
)
Removes an attribute by the name indicated in the
name
parameter. If the removed
attribute has a default value in the DTD, that value is
immediately substituted upon its removal.
removeAttributeNS(
namespaceURI, localName
)
Removes an attribute that matches both the local name and namespace supplied. If the attribute had a default value specified in the DTD, that value is immediately substituted upon removal.
removeAttributeNode(
node
)
This method removes the specified attribute
node
. This method takes a complete
Attr
object as a parameter
as opposed to a string name, as is the case with the removeAttribute
methods. Return
value is the removed node.
setAttribute(
name, value
)
This method adds a new attribute to the Element
with the supplied
name
/value
pair. It replaces any elements that already exist with the
same name. The text supplied as value is placed as a literal
string, so any EntityReference
or other more
complex Attr
structures are
not created (see setAttributeNode
instead).
setAttributeNS(
namesapceURI, qualifiedName, value
)
This method works essentially the same as setAttribute
, except a namespace URI
and prefix are associated with the attribute.
setAttributeNode(
node
)
This method adds a new attribute to the Element
. If the supplied
node
parameter (of type Attr
) contains any Text
node or EntityReference
children, they are
added as well. If an attribute with a matching nodeName
already exists within the
element, it is replaced. Returns None
unless an attribute is
replaced, in which case the old attribute is returned to the
caller.
setAttributeNodeNS(
node
)
This method works essentially the same as setAttributeNode
. If a node already
exists with the same namespace URI and local name, it is
replaced and returned to the caller. Otherwise, the new
attribute is added and None
is returned.
18.188.37.136