.TH "DOM::Element" 3 "28 Jan 2004" "khtml Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
DOM::Element \- By far the vast majority of objects (apart from text) that authors encounter when traversing a document are \fC \fBElement\fP \fP nodes.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <dom_element.h>\fP
.PP
Inherits \fBDOM::Node\fP.
.PP
Inherited by \fBDOM::HTMLElement\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBElement\fP (const  \fBNode\fP &other)"
.br
.ti -1c
.RI "\fBElement\fP (const  \fBElement\fP &other)"
.br
.ti -1c
.RI "\fBElement\fP & \fBoperator=\fP (const  \fBNode\fP &other)"
.br
.ti -1c
.RI "\fBElement\fP & \fBoperator=\fP (const  \fBElement\fP &other)"
.br
.ti -1c
.RI "\fBDOMString\fP \fBtagName\fP () const "
.br
.RI "\fIThe name of the element. \fP"
.ti -1c
.RI "\fBDOMString\fP \fBgetAttribute\fP (const  \fBDOMString\fP &name)"
.br
.RI "\fIRetrieves an attribute value by name. \fP"
.ti -1c
.RI "void \fBsetAttribute\fP (const  \fBDOMString\fP &name, const  \fBDOMString\fP &value)"
.br
.RI "\fIAdds a new attribute. \fP"
.ti -1c
.RI "void \fBremoveAttribute\fP (const  \fBDOMString\fP &name)"
.br
.RI "\fIRemoves an attribute by name. \fP"
.ti -1c
.RI "\fBAttr\fP \fBgetAttributeNode\fP (const  \fBDOMString\fP &name)"
.br
.RI "\fIRetrieves an \fC \fBAttr\fP \fP node by name. \fP"
.ti -1c
.RI "\fBAttr\fP \fBsetAttributeNode\fP (const  \fBAttr\fP &newAttr)"
.br
.RI "\fIAdds a new attribute. \fP"
.ti -1c
.RI "\fBAttr\fP \fBremoveAttributeNode\fP (const  \fBAttr\fP &oldAttr)"
.br
.RI "\fIRemoves the specified attribute. \fP"
.ti -1c
.RI "\fBNodeList\fP \fBgetElementsByTagName\fP (const  \fBDOMString\fP &name)"
.br
.RI "\fIReturns a \fC \fBNodeList\fP \fP of all descendant elements with a given tag name, in the order in which they would be encountered in a preorder traversal of the \fC \fBElement\fP \fP tree. \fP"
.ti -1c
.RI "\fBNodeList\fP \fBgetElementsByTagNameNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &localName)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2 Returns a \fBNodeList\fP of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this \fBElement\fP tree. \fP"
.ti -1c
.RI "\fBDOMString\fP \fBgetAttributeNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &localName)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "void \fBsetAttributeNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &qualifiedName, const  \fBDOMString\fP &value)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "void \fBremoveAttributeNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &localName)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "\fBAttr\fP \fBgetAttributeNodeNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &localName)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "\fBAttr\fP \fBsetAttributeNodeNS\fP (const  \fBAttr\fP &newAttr)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "bool \fBhasAttribute\fP (const  \fBDOMString\fP &name)"
.br
.RI "\fIReturns true when an attribute with a given name is specified on this element or has a default value, false otherwise. \fP"
.ti -1c
.RI "bool \fBhasAttributeNS\fP (const  \fBDOMString\fP &namespaceURI, const  \fBDOMString\fP &localName)"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2. \fP"
.ti -1c
.RI "\fBCSSStyleDeclaration\fP \fBstyle\fP ()"
.br
.RI "\fIIntroduced in \fBDOM\fP Level 2 This method is from the \fBCSSStyleDeclaration\fP interface. \fP"
.ti -1c
.RI "bool \fBisHTMLElement\fP () const "
.br
.ti -1c
.RI "\fBElement\fP \fBform\fP () const "
.br
.RI "\fIKHTML extension to \fBDOM\fP This method returns the associated form element. \fP"
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "bool \fBkhtmlValidAttrName\fP (const  \fBDOMString\fP &name)"
.br
.ti -1c
.RI "bool \fBkhtmlValidPrefix\fP (const  \fBDOMString\fP &name)"
.br
.ti -1c
.RI "bool \fBkhtmlValidQualifiedName\fP (const  \fBDOMString\fP &name)"
.br
.ti -1c
.RI "bool \fBkhtmlMalformedQualifiedName\fP (const  \fBDOMString\fP &name)"
.br
.ti -1c
.RI "bool \fBkhtmlMalformedPrefix\fP (const  \fBDOMString\fP &name)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "\fBElement\fP (ElementImpl *_impl)"
.br
.in -1c
.SS "Friends"

.in +1c
.ti -1c
.RI "class \fBDocument\fP"
.br
.ti -1c
.RI "class \fBHTMLDocument\fP"
.br
.ti -1c
.RI "class \fBAttr\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
By far the vast majority of objects (apart from text) that authors encounter when traversing a document are \fC \fBElement\fP \fP nodes. 

Assume the following XML document: <elementExample id=''demo''> <subelement1/> <subelement2><subsubelement/></subelement2> </elementExample>
.PP
When represented using \fBDOM\fP, the top node is an \fC \fBElement\fP \fP node for ''elementExample'', which contains two child \fC \fBElement\fP \fP nodes, one for ''subelement1'' and one for ''subelement2''. ''subelement1'' contains no child nodes.
.PP
Elements may have attributes associated with them; since the \fC \fBElement\fP \fP interface inherits from \fC \fBNode\fP \fP , the generic \fC \fBNode\fP \fP interface method \fC getAttributes \fP may be used to retrieve the set of all attributes for an element. There are methods on the \fC \fBElement\fP \fP interface to retrieve either an \fC \fBAttr\fP \fP object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an \fC \fBAttr\fP \fP object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a convenience. 
.PP
Definition at line 207 of file dom_element.h.
.SH "Member Function Documentation"
.PP 
.SS "\fBDOMString\fP Element::tagName () const"
.PP
The name of the element. For example, in: <elementExample id=''demo''> ... </elementExample> , \fC tagName \fP has the value \fC ''elementExample'' \fP . Note that this is case-preserving in XML, as are all of the operations of the \fBDOM\fP. The HTML \fBDOM\fP returns the \fC tagName \fP of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document. Definition at line 145 of file dom_element.cpp.
.SS "\fBDOMString\fP Element::getAttribute (const \fBDOMString\fP & name)"
.PP
Retrieves an attribute value by name. \fBParameters:\fP
.RS 4
\fIname\fP The name of the attribute to retrieve.
.RE
.PP
\fBReturns:\fP
.RS 4
The \fC \fBAttr\fP \fP value as a string, or the empty string if that attribute does not have a specified or default value. 
.RE
.PP
Definition at line 151 of file dom_element.cpp.
.PP
References getAttributeNS(), and KStdAccel::name().
.SS "void Element::setAttribute (const \fBDOMString\fP & name, const \fBDOMString\fP & value)"
.PP
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string, it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an \fC \fBAttr\fP \fP node plus any \fC \fBText\fP \fP and \fC \fBEntityReference\fP \fP nodes, build the appropriate subtree, and use \fC setAttributeNode \fP to assign it as the value of an attribute.
.PP
\fBParameters:\fP
.RS 4
\fIname\fP The name of the attribute to create or alter.
.br
\fIvalue\fP Value to set in string form.
.RE
.PP
\fBReturns:\fP
.RS 4
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
.RE
.PP
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. Definition at line 156 of file dom_element.cpp.
.PP
References KStdAccel::name(), and setAttributeNS().
.SS "void Element::removeAttribute (const \fBDOMString\fP & name)"
.PP
Removes an attribute by name. If the removed attribute has a default value it is immediately replaced.
.PP
\fBParameters:\fP
.RS 4
\fIname\fP The name of the attribute to remove.
.RE
.PP
\fBReturns:\fP
.RS 4
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 
.RE
.PP
Definition at line 161 of file dom_element.cpp.
.PP
References KStdAccel::name(), and removeAttributeNS().
.SS "\fBAttr\fP Element::getAttributeNode (const \fBDOMString\fP & name)"
.PP
Retrieves an \fC \fBAttr\fP \fP node by name. \fBParameters:\fP
.RS 4
\fIname\fP The name of the attribute to retrieve.
.RE
.PP
\fBReturns:\fP
.RS 4
The \fC \fBAttr\fP \fP node with the specified attribute name or \fC null \fP if there is no such attribute. 
.RE
.PP
Definition at line 166 of file dom_element.cpp.
.PP
References getAttributeNodeNS(), and KStdAccel::name().
.SS "\fBAttr\fP Element::setAttributeNode (const \fBAttr\fP & newAttr)"
.PP
Adds a new attribute. If an attribute with that name is already present in the element, it is replaced by the new one.
.PP
\fBParameters:\fP
.RS 4
\fInewAttr\fP The \fC \fBAttr\fP \fP node to add to the attribute list.
.RE
.PP
\fBReturns:\fP
.RS 4
If the \fC newAttr \fP attribute replaces an existing attribute with the same name, the previously existing \fC \fBAttr\fP \fP node is returned, otherwise \fC null \fP is returned.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP WRONG_DOCUMENT_ERR: Raised if \fC newAttr \fP was created from a different document than the one that created the element.
.RE
.PP
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
.PP
INUSE_ATTRIBUTE_ERR: Raised if \fC newAttr \fP is already an attribute of another \fC \fBElement\fP \fP object. The \fBDOM\fP user must explicitly clone \fC \fBAttr\fP \fP nodes to re-use them in other elements. Definition at line 171 of file dom_element.cpp.
.PP
References setAttributeNodeNS().
.SS "\fBAttr\fP Element::removeAttributeNode (const \fBAttr\fP & oldAttr)"
.PP
Removes the specified attribute. \fBParameters:\fP
.RS 4
\fIoldAttr\fP The \fC \fBAttr\fP \fP node to remove from the attribute list. If the removed \fC \fBAttr\fP \fP has a default value it is immediately replaced.
.RE
.PP
\fBReturns:\fP
.RS 4
The \fC \fBAttr\fP \fP node that was removed.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
.RE
.PP
NOT_FOUND_ERR: Raised if \fC oldAttr \fP is not an attribute of the element. Definition at line 176 of file dom_element.cpp.
.PP
References DOM::Node::handle(), DOM::Node::isNull(), and DOM::Attr::ownerElement().
.SS "\fBNodeList\fP Element::getElementsByTagName (const \fBDOMString\fP & name)"
.PP
Returns a \fC \fBNodeList\fP \fP of all descendant elements with a given tag name, in the order in which they would be encountered in a preorder traversal of the \fC \fBElement\fP \fP tree. \fBParameters:\fP
.RS 4
\fIname\fP The name of the tag to match on. The special value '*' matches all tags.
.RE
.PP
\fBReturns:\fP
.RS 4
A list of matching \fC \fBElement\fP \fP nodes. 
.RE
.PP
Definition at line 192 of file dom_element.cpp.
.PP
References getElementsByTagNameNS(), and KStdAccel::name().
.SS "\fBNodeList\fP Element::getElementsByTagNameNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2 Returns a \fBNodeList\fP of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this \fBElement\fP tree. \fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the elements to match on. The special value '*' matches all namespaces.
.br
\fIlocalName\fP The local name of the elements to match on. The special value '*' matches all local names.
.RE
.PP
\fBReturns:\fP
.RS 4
A new \fBNodeList\fP object containing all the matched Elements. 
.RE
.PP
Definition at line 199 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.PP
Referenced by getElementsByTagName().
.SS "\fBDOMString\fP Element::getAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. No Exceptions.
.PP
Retrieves an attribute value by local name and namespace URI. HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the attribute to retrieve.
.br
\fIlocalName\fP The local name of the attribute to retrieve.
.RE
.PP
\fBReturns:\fP
.RS 4
The \fBAttr\fP value as a string, or the empty string if that attribute does not have a specified or default value. 
.RE
.PP
Definition at line 207 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.PP
Referenced by getAttribute().
.SS "void Element::setAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & qualifiedName, const \fBDOMString\fP & value)"
.PP
Introduced in \fBDOM\fP Level 2. Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an \fBAttr\fP node plus any \fBText\fP and \fBEntityReference\fP nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.
.PP
HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the attribute to create or alter.
.br
\fIqualifiedName\fP The qualified name of the attribute to create or alter.
.br
\fIvalue\fP The value to set in string form.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
.RE
.PP
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
.PP
NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is 'xml' and the namespaceURI is different from 'http://www.w3.org/XML/1998/namespace', or if the qualifiedName is 'xmlns' and the namespaceURI is different from 'http://www.w3.org/2000/xmlns/'. Definition at line 218 of file dom_element.cpp.
.PP
References DOM::DOMString::find(), DOM::DOMString::implementation(), DOM::Node::localName(), and DOM::DOMString::remove().
.PP
Referenced by setAttribute().
.SS "void Element::removeAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
.PP
HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the attribute to remove.
.br
\fIlocalName\fP The local name of the attribute to remove.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 
.RE
.PP
Definition at line 241 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.PP
Referenced by removeAttribute().
.SS "\fBAttr\fP Element::getAttributeNodeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. Retrieves an \fBAttr\fP node by local name and namespace URI. HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the attribute to retrieve.
.br
\fIlocalName\fP The local name of the attribute to retrieve.
.RE
.PP
\fBReturns:\fP
.RS 4
The \fBAttr\fP node with the specified attribute local name and namespace URI or null if there is no such attribute. 
.RE
.PP
Definition at line 256 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.PP
Referenced by getAttributeNode().
.SS "\fBAttr\fP Element::setAttributeNodeNS (const \fBAttr\fP & newAttr)"
.PP
Introduced in \fBDOM\fP Level 2. Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.
.PP
HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInewAttr\fP The \fBAttr\fP node to add to the attribute list.
.RE
.PP
\fBReturns:\fP
.RS 4
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced \fBAttr\fP node is returned, otherwise null is returned.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP WRONG_DOCUMENT_ERR: Raised if newAttr was created from a different document than the one that created the element.
.RE
.PP
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
.PP
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an attribute of another \fBElement\fP object. The \fBDOM\fP user must explicitly clone \fBAttr\fP nodes to re-use them in other elements. Definition at line 271 of file dom_element.cpp.
.PP
References DOM::Node::handle(), and DOM::Node::isNull().
.PP
Referenced by setAttributeNode().
.SS "bool Element::hasAttribute (const \fBDOMString\fP & name)"
.PP
Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise. Introduced in \fBDOM\fP Level 2.
.PP
\fBParameters:\fP
.RS 4
\fIname\fP The name of the attribute to look for.
.RE
.PP
\fBReturns:\fP
.RS 4
true if an attribute with the given name is specified on this element or has a default value, false otherwise. 
.RE
.PP
Definition at line 285 of file dom_element.cpp.
.PP
References hasAttributeNS(), and KStdAccel::name().
.SS "bool Element::hasAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. HTML-only \fBDOM\fP implementations do not need to implement this method.
.PP
\fBParameters:\fP
.RS 4
\fInamespaceURI\fP The namespace URI of the attribute to look for.
.br
\fIlocalName\fP The local name of the attribute to look for.
.RE
.PP
\fBReturns:\fP
.RS 4
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise. 
.RE
.PP
Definition at line 290 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.PP
Referenced by hasAttribute().
.SS "\fBCSSStyleDeclaration\fP Element::style ()"
.PP
Introduced in \fBDOM\fP Level 2 This method is from the \fBCSSStyleDeclaration\fP interface. The style attribute Definition at line 315 of file dom_element.cpp.
.SS "\fBElement\fP Element::form () const"
.PP
KHTML extension to \fBDOM\fP This method returns the associated form element. returns null if this element is not a form-like element or if this elment is not in the scope of a form element. Reimplemented in \fBDOM::HTMLButtonElement\fP, \fBDOM::HTMLFieldSetElement\fP, \fBDOM::HTMLInputElement\fP, \fBDOM::HTMLLegendElement\fP, \fBDOM::HTMLSelectElement\fP, \fBDOM::HTMLTextAreaElement\fP, \fBDOM::HTMLOptionElement\fP, \fBDOM::HTMLIsIndexElement\fP, and \fBDOM::HTMLObjectElement\fP.
.PP
Definition at line 309 of file dom_element.cpp.

.SH "Author"
.PP 
Generated automatically by Doxygen for khtml Library from the source code.
