.TH "DOM::Element" kde3 "11 Jun 2005" "Version Version 3.4.1" "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
.ti -1c
.RI "\fBDOMString\fP \fBgetAttribute\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "void \fBsetAttribute\fP (const \fBDOMString\fP &name, const \fBDOMString\fP &value)"
.br
.ti -1c
.RI "void \fBremoveAttribute\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "\fBAttr\fP \fBgetAttributeNode\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "\fBAttr\fP \fBsetAttributeNode\fP (const \fBAttr\fP &newAttr)"
.br
.ti -1c
.RI "\fBAttr\fP \fBremoveAttributeNode\fP (const \fBAttr\fP &oldAttr)"
.br
.ti -1c
.RI "\fBNodeList\fP \fBgetElementsByTagName\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "\fBNodeList\fP \fBgetElementsByTagNameNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &localName)"
.br
.ti -1c
.RI "\fBDOMString\fP \fBgetAttributeNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &localName)"
.br
.ti -1c
.RI "void \fBsetAttributeNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &qualifiedName, const \fBDOMString\fP &value)"
.br
.ti -1c
.RI "void \fBremoveAttributeNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &localName)"
.br
.ti -1c
.RI "\fBAttr\fP \fBgetAttributeNodeNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &localName)"
.br
.ti -1c
.RI "\fBAttr\fP \fBsetAttributeNodeNS\fP (const \fBAttr\fP &newAttr)"
.br
.ti -1c
.RI "bool \fBhasAttribute\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "bool \fBhasAttributeNS\fP (const \fBDOMString\fP &namespaceURI, const \fBDOMString\fP &localName)"
.br
.ti -1c
.RI "\fBCSSStyleDeclaration\fP \fBstyle\fP ()"
.br
.ti -1c
.RI "bool \fBcontentEditable\fP () const "
.br
.ti -1c
.RI "void \fBsetContentEditable\fP (bool enabled)"
.br
.ti -1c
.RI "bool \fBisHTMLElement\fP () const "
.br
.ti -1c
.RI "\fBElement\fP \fBform\fP () const "
.br
.in -1c
.SS "Static Public Member Functions"

.in +1c
.ti -1c
.RI "static bool \fBkhtmlValidAttrName\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "static bool \fBkhtmlValidPrefix\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "static bool \fBkhtmlValidQualifiedName\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "static bool \fBkhtmlMalformedQualifiedName\fP (const \fBDOMString\fP &name)"
.br
.ti -1c
.RI "static 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 \fCgetAttributes\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 210 of file dom_element.h.
.SH "Member Function Documentation"
.PP 
.SS "\fBDOMString\fP Element::tagName () const"
.PP
The name of the element. 
.PP
For example, in: <elementExample id=''demo''> ... </elementExample> , \fCtagName\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 \fCtagName\fP of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document. 
.PP
Definition at line 141 of file dom_element.cpp.
.PP
Referenced by getElementsByTagName().
.SS "\fBDOMString\fP Element::getAttribute (const \fBDOMString\fP & name)"
.PP
Retrieves an attribute value by name. 
.PP
\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

.PP
Definition at line 147 of file dom_element.cpp.
.PP
Referenced by DOM::HTMLOptionElement::defaultSelected().
.SS "void Element::setAttribute (const \fBDOMString\fP & name, const \fBDOMString\fP & value)"
.PP
Adds a new attribute. 
.PP
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 \fCsetAttributeNode\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. 
.PP
Definition at line 162 of file dom_element.cpp.
.SS "void Element::removeAttribute (const \fBDOMString\fP & name)"
.PP
Removes an attribute by name. 
.PP
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

.PP
Definition at line 174 of file dom_element.cpp.
.PP
References DOM::NamedNodeMap::removeNamedItem().
.SS "\fBAttr\fP Element::getAttributeNode (const \fBDOMString\fP & name)"
.PP
Retrieves an \fC\fBAttr\fP\fP node by name. 
.PP
\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 \fCnull\fP if there is no such attribute. 
.RE
.PP

.PP
Definition at line 188 of file dom_element.cpp.
.SS "\fBAttr\fP Element::setAttributeNode (const \fBAttr\fP & newAttr)"
.PP
Adds a new attribute. 
.PP
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 \fCnewAttr\fP attribute replaces an existing attribute with the same name, the previously existing \fC\fBAttr\fP\fP node is returned, otherwise \fCnull\fP is returned.
.RE
.PP
\fBExceptions:\fP
.RS 4
\fIDOMException\fP WRONG_DOCUMENT_ERR: Raised if \fCnewAttr\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 \fCnewAttr\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. 
.PP
Definition at line 201 of file dom_element.cpp.
.PP
References DOM::Node::attributes(), and DOM::NamedNodeMap::setNamedItem().
.SS "\fBAttr\fP Element::removeAttributeNode (const \fBAttr\fP & oldAttr)"
.PP
Removes the specified attribute. 
.PP
\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 \fColdAttr\fP is not an attribute of the element. 
.PP
Definition at line 216 of file dom_element.cpp.
.PP
References DOM::Node::attributes().
.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. 
.PP
\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

.PP
Definition at line 231 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation(), and tagName().
.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. 
.PP
\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

.PP
Definition at line 242 of file dom_element.cpp.
.SS "\fBDOMString\fP Element::getAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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

.PP
Definition at line 249 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.SS "void Element::setAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & qualifiedName, const \fBDOMString\fP & value)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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/'. 
.PP
Definition at line 259 of file dom_element.cpp.
.SS "void Element::removeAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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

.PP
Definition at line 271 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation(), and DOM::NamedNodeMap::removeNamedItem().
.SS "\fBAttr\fP Element::getAttributeNodeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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

.PP
Definition at line 284 of file dom_element.cpp.
.PP
References DOM::DOMString::implementation().
.SS "\fBAttr\fP Element::setAttributeNodeNS (const \fBAttr\fP & newAttr)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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. 
.PP
Definition at line 297 of file dom_element.cpp.
.PP
References DOM::Node::attributes(), and DOM::NamedNodeMap::setNamedItem().
.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. 
.PP
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

.PP
Definition at line 312 of file dom_element.cpp.
.PP
References DOM::Node::attributes().
.SS "bool Element::hasAttributeNS (const \fBDOMString\fP & namespaceURI, const \fBDOMString\fP & localName)"
.PP
Introduced in \fBDOM\fP Level 2. 
.PP
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

.PP
Definition at line 322 of file dom_element.cpp.
.PP
References DOM::Node::attributes(), and DOM::DOMString::implementation().
.SS "\fBCSSStyleDeclaration\fP Element::style ()"
.PP
Introduced in \fBDOM\fP Level 2 This method is from the \fBCSSStyleDeclaration\fP interface. 
.PP
The style attribute 
.PP
Definition at line 349 of file dom_element.cpp.
.SS "bool Element::contentEditable () const"
.PP
not part of the official \fBDOM\fP 
.PP
This method will always reflect the editability setting of this element as specified by a direct or indirect (that means, inherited) assignment to contentEditable or the respective CSS rule, even if design mode is active.
.PP
\fBReturns:\fP
.RS 4
whether this element is editable. 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetContentEditable\fP 
.RE
.PP

.PP
Definition at line 355 of file dom_element.cpp.
.SS "void Element::setContentEditable (bool enabled)"
.PP
not part of the official \fBDOM\fP 
.PP
This element can be made editable by setting its contentEditable property to \fCtrue\fP. The setting will be inherited to its children as well.
.PP
Setting or clearing contentEditable when design mode is active will take no effect. However, its status will still be propagated to all child elements.
.PP
\fBParameters:\fP
.RS 4
\fIenabled\fP \fCtrue\fP to make this element editable, \fCfalse\fP otherwise. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBDOM::Document::designMode\fP 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 
.RE
.PP

.PP
Definition at line 360 of file dom_element.cpp.
.SS "\fBElement\fP Element::form () const"
.PP
KHTML extension to \fBDOM\fP This method returns the associated form element. 
.PP
returns null if this element is not a form-like element or if this elment is not in the scope of a form element. 
.PP
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 338 of file dom_element.cpp.
.PP
Referenced by DOM::HTMLIsIndexElement::form(), DOM::HTMLOptionElement::form(), DOM::HTMLTextAreaElement::form(), DOM::HTMLSelectElement::form(), DOM::HTMLLegendElement::form(), DOM::HTMLInputElement::form(), DOM::HTMLFieldSetElement::form(), and DOM::HTMLButtonElement::form().

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