[All Packages]  [This Package]  [Previous Class]  [Next Class]

Class: Element

This class contains methods pertaining to element nodes.


Method Index

getTagName Return the node's tag name
getAttribute Select an attribute given its name
setAttribute Create a new attribute given its name and value
removeAttribute Remove an attribute given its name
getAttributeNode Remove an attribute given its name
setAttributeNode Add a new attribute node
removeAttributeNode Remove an attribute node
getElementsByTagName Return a list of element nodes with the given tag name
getElementsByTagNameNS Return a list of element nodes with the given tag name (namespace aware)
normalize "Normalize" an element (merge adjacent text nodes)
initialize Initialize a new element node

Methods

getTagName

Function:
Return the tag name of the element. The DOM says: "...even though there is a generic nodeName attribute on the Node interface, there is still a tagName attribute on the Element interface; these two attributes must contain the same value, but the Working Group considers it worthwhile to support both, given the different constituencies the DOM API must satisfy

Prototype:
DOMString getTagName()

Arguments:
None

Returns:
DOMString -- Tag name of node

getAttribute

Function:
Return "value" (definition) of named attribute

Prototype:
DOMString getAttribute(DOMString name)

Arguments:
name -- name of attribute
Returns:
Value of attribute


setAttribute

Function:
Create a new attribute
Prototype:
Attr* setAttribute(DOMString name, DOMString value)

Arguments:
name -- name of new attribute
value -- value of new attribute
Returns:
Pointer to create attribute


removeAttribute

Function:
Removes the named attribute

Prototype:
void removeAttribute(DOMString name)

Arguments:
name -- name of attribute to remove

Returns:
None


getAttributeNode

Function:
Return pointer to named attribute

Prototype:
Attr* getAttributeNode(DOMString name)

Arguments:
name -- name of attribute

Returns:
Attr* -- pointer to attribute, or NULL if none such


setAttributeNode

Function:
Set (add) new attribute

Prototype:
boolean setAttributeNode(Attr* newAttr, Attr** oldAttr)

Arguments:
newAttr -- pointer to new attribute
oldAttr -- returned pointer to replaced attribute

Returns:
boolean -- success


removeAttributeNode

Function:
Remove the named attribute

Prototype:
Attr* removeAttributeNode(Attr* oldAttr)

Arguments:
oldAttr -- attribute to remove

Returns:
Attr* -- oldAttr passed back


getElementsByTagName

Function:
Create a list of matching elements

Prototype:
NodeList* getElementsByTagName(DOMString name)

Arguments:
name -- tagname to match, "*" for all

Returns:
NodeList* -- list of matches


getElementsByTagNameNS

Function:
Create a list of matching elements

Prototype:
NodeList* getElementsByTagNameNS(DOMString nspuri, DOMString local)

Arguments:
nspuri -- namespace URI
local -- local name to match, "*" for all

Returns:
NodeList* -- list of matches


normalize

Function:
Normalize an element, i.e. merge all adjacent TEXT nodes

Prototype:
void normalize(void)

Arguments:
None

Returns:
None

initialize

Function:
Initialize a newly allocated element node

Prototype:
uword initialize(Document *doc, DOMString nspuri, DOMString qname)

Arguments:
doc -- XML document
nspuri -- namespace URI
qname -- qualified name

Returns:
0 on success or an error code on failure