1QDomElement(3qt)                                              QDomElement(3qt)
2
3
4

NAME

6       QDomElement - Represents one element in the DOM tree
7

SYNOPSIS

9       All the functions in this class are reentrant when Qt is built with
10       thread support.</p>
11
12       #include <qdom.h>
13
14       Inherits QDomNode.
15
16   Public Members
17       QDomElement ()
18       QDomElement ( const QDomElement & x )
19       QDomElement & operator= ( const QDomElement & x )
20       ~QDomElement ()
21       QString attribute ( const QString & name, const QString & defValue =
22           QString::null ) const
23       void setAttribute ( const QString & name, const QString & value )
24       void setAttribute ( const QString & name, int value )
25       void setAttribute ( const QString & name, uint value )
26       void setAttribute ( const QString & name, long value )
27       void setAttribute ( const QString & name, ulong value )
28       void setAttribute ( const QString & name, double value )
29       void removeAttribute ( const QString & name )
30       QDomAttr attributeNode ( const QString & name )
31       QDomAttr setAttributeNode ( const QDomAttr & newAttr )
32       QDomAttr removeAttributeNode ( const QDomAttr & oldAttr )
33       virtual QDomNodeList elementsByTagName ( const QString & tagname )
34           const
35       bool hasAttribute ( const QString & name ) const
36       QString attributeNS ( const QString nsURI, const QString & localName,
37           const QString & defValue ) const
38       void setAttributeNS ( const QString nsURI, const QString & qName, const
39           QString & value )
40       void setAttributeNS ( const QString nsURI, const QString & qName, int
41           value )
42       void setAttributeNS ( const QString nsURI, const QString & qName, uint
43           value )
44       void setAttributeNS ( const QString nsURI, const QString & qName, long
45           value )
46       void setAttributeNS ( const QString nsURI, const QString & qName, ulong
47           value )
48       void setAttributeNS ( const QString nsURI, const QString & qName,
49           double value )
50       void removeAttributeNS ( const QString & nsURI, const QString &
51           localName )
52       QDomAttr attributeNodeNS ( const QString & nsURI, const QString &
53           localName )
54       QDomAttr setAttributeNodeNS ( const QDomAttr & newAttr )
55       virtual QDomNodeList elementsByTagNameNS ( const QString & nsURI, const
56           QString & localName ) const
57       bool hasAttributeNS ( const QString & nsURI, const QString & localName
58           ) const
59       QString tagName () const
60       void setTagName ( const QString & name )
61       virtual QDomNamedNodeMap attributes () const
62       virtual QDomNode::NodeType nodeType () const
63       virtual bool isElement () const
64       QString text () const
65

DESCRIPTION

67       The QDomElement class represents one element in the DOM tree.
68
69       Elements have a tagName() and zero or more attributes associated with
70       them. The tag name can be changed with setTagName().
71
72       Element attributes are represented by QDomAttr objects that can be
73       queried using the attribute() and attributeNode() functions. You can
74       set attributes with the setAttribute() and setAttributeNode()
75       functions. Attributes can be removed with removeAttribute(). There are
76       namespace-aware equivalents to these functions, i.e. setAttributeNS(),
77       setAttributeNodeNS() and removeAttributeNS().
78
79       If you want to access the text of a node use text(), e.g.
80
81           QDomElement e = //...
82           //...
83           QString s = e.text()
84       The text() function operates recursively to find the text (since not
85       all elements contain text). If you want to find all the text in all of
86       a node's children, iterate over the children looking for QDomText
87       nodes, e.g.
88
89           QString text;
90           QDomElement element = doc.documentElement();
91           for( QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling() )
92           {
93               QDomText t = n.toText();
94               if ( !t.isNull() )
95                   text += t.data();
96           }
97       Note that we attempt to convert each node to a text node and use text()
98       rather than using firstChild().toText().data() or n.toText().data()
99       directly on the node, because the node may not be a text element.
100
101       You can get a list of all the decendents of an element which have a
102       specified tag name with elementsByTagName() or elementsByTagNameNS().
103
104       For further information about the Document Object Model see
105       http://www.w3.org/TR/REC-DOM-Level-1/ and http://www.w3.org/TR/DOM-
106       Level-2-Core/. For a more general introduction of the DOM
107       implementation see the QDomDocument documentation.
108
109       See also XML.
110

MEMBER FUNCTION DOCUMENTATION

QDomElement::QDomElement ()

113       Constructs an empty element. Use the QDomDocument::createElement()
114       function to construct elements with content.
115

QDomElement::QDomElement ( const QDomElement & x )

117       Constructs a copy of x.
118
119       The data of the copy is shared (shallow copy): modifying one node will
120       also change the other. If you want to make a deep copy, use
121       cloneNode().
122

QDomElement::~QDomElement ()

124       Destroys the object and frees its resources.
125

QString QDomElement::attribute ( const QString & name, const QString &

127       defValue = QString::null ) const
128       Returns the attribute called name. If the attribute does not exist
129       defValue is returned.
130
131       See also setAttribute(), attributeNode(), setAttributeNode(), and
132       attributeNS().
133

QString QDomElement::attributeNS ( const QString nsURI, const QString &

135       localName, const QString & defValue ) const
136       Returns the attribute with the local name localName and the namespace
137       URI nsURI. If the attribute does not exist defValue is returned.
138
139       See also setAttributeNS(), attributeNodeNS(), setAttributeNodeNS(), and
140       attribute().
141

QDomAttr QDomElement::attributeNode ( const QString & name )

143       Returns the QDomAttr object that corresponds to the attribute called
144       name. If no such attribute exists a null attribute is returned.
145
146       See also setAttributeNode(), attribute(), setAttribute(), and
147       attributeNodeNS().
148

QDomAttr QDomElement::attributeNodeNS ( const QString & nsURI, const QString &

150       localName )
151       Returns the QDomAttr object that corresponds to the attribute with the
152       local name localName and the namespace URI nsURI. If no such attribute
153       exists a null attribute is returned.
154
155       See also setAttributeNode(), attribute(), and setAttribute().
156

QDomNamedNodeMap QDomElement::attributes () const [virtual]

158       Returns a QDomNamedNodeMap containing all this element's attributes.
159
160       See also attribute(), setAttribute(), attributeNode(), and
161       setAttributeNode().
162
163       Reimplemented from QDomNode.
164

QDomNodeList QDomElement::elementsByTagName ( const QString & tagname ) const

166       [virtual]
167       Returns a QDomNodeList containing all descendent elements of this
168       element that are called tagname. The order they are in the node list is
169       the order they are encountered in a preorder traversal of the element
170       tree.
171
172       See also elementsByTagNameNS() and QDomDocument::elementsByTagName().
173

QDomNodeList QDomElement::elementsByTagNameNS ( const QString & nsURI, const

175       QString & localName ) const [virtual]
176       Returns a QDomNodeList containing all the descendent elements of this
177       element with the local name localName and the namespace URI nsURI. The
178       order they are in the node list is the order they are encountered in a
179       preorder traversal of the element tree.
180
181       See also elementsByTagName() and QDomDocument::elementsByTagNameNS().
182

bool QDomElement::hasAttribute ( const QString & name ) const

184       Returns TRUE if this element has an attribute called name; otherwise
185       returns FALSE.
186

bool QDomElement::hasAttributeNS ( const QString & nsURI, const QString &

188       localName ) const
189       Returns TRUE if this element has an attribute with the local name
190       localName and the namespace URI nsURI; otherwise returns FALSE.
191

bool QDomElement::isElement () const [virtual]

193       Returns TRUE.
194
195       Reimplemented from QDomNode.
196

QDomNode::NodeType QDomElement::nodeType () const [virtual]

198       Returns ElementNode.
199
200       Reimplemented from QDomNode.
201

QDomElement & QDomElement::operator= ( const QDomElement & x )

203       Assigns x to this DOM element.
204
205       The data of the copy is shared (shallow copy): modifying one node will
206       also change the other. If you want to make a deep copy, use
207       cloneNode().
208

void QDomElement::removeAttribute ( const QString & name )

210       Removes the attribute called name name from this element.
211
212       See also setAttribute(), attribute(), and removeAttributeNS().
213

void QDomElement::removeAttributeNS ( const QString & nsURI, const QString &

215       localName )
216       Removes the attribute with the local name localName and the namespace
217       URI nsURI from this element.
218
219       See also setAttributeNS(), attributeNS(), and removeAttribute().
220

QDomAttr QDomElement::removeAttributeNode ( const QDomAttr & oldAttr )

222       Removes the attribute oldAttr from the element and returns it.
223
224       See also attributeNode() and setAttributeNode().
225

void QDomElement::setAttribute ( const QString & name, const QString & value )

227
228       Adds an attribute called name with value value. If an attribute with
229       the same name exists, its value is replaced by value.
230
231       See also attribute(), setAttributeNode(), and setAttributeNS().
232

void QDomElement::setAttribute ( const QString & name, int value )

234       This is an overloaded member function, provided for convenience. It
235       behaves essentially like the above function.
236

void QDomElement::setAttribute ( const QString & name, uint value )

238       This is an overloaded member function, provided for convenience. It
239       behaves essentially like the above function.
240

void QDomElement::setAttribute ( const QString & name, long value )

242       This is an overloaded member function, provided for convenience. It
243       behaves essentially like the above function.
244

void QDomElement::setAttribute ( const QString & name, ulong value )

246       This is an overloaded member function, provided for convenience. It
247       behaves essentially like the above function.
248

void QDomElement::setAttribute ( const QString & name, double value )

250       This is an overloaded member function, provided for convenience. It
251       behaves essentially like the above function.
252

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

254       const QString & value )
255       Adds an attribute with the qualified name qName and the namespace URI
256       nsURI with the value value. If an attribute with the same local name
257       and namespace URI exists, its prefix is replaced by the prefix of qName
258       and its value is repaced by value.
259
260       Although qName is the qualified name, the local name is used to decide
261       if an existing attribute's value should be replaced.
262
263       See also attributeNS(), setAttributeNodeNS(), and setAttribute().
264

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

266       int value )
267       This is an overloaded member function, provided for convenience. It
268       behaves essentially like the above function.
269

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

271       uint value )
272       This is an overloaded member function, provided for convenience. It
273       behaves essentially like the above function.
274

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

276       long value )
277       This is an overloaded member function, provided for convenience. It
278       behaves essentially like the above function.
279

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

281       ulong value )
282       This is an overloaded member function, provided for convenience. It
283       behaves essentially like the above function.
284

void QDomElement::setAttributeNS ( const QString nsURI, const QString & qName,

286       double value )
287       This is an overloaded member function, provided for convenience. It
288       behaves essentially like the above function.
289

QDomAttr QDomElement::setAttributeNode ( const QDomAttr & newAttr )

291       Adds the attribute newAttr to this element.
292
293       If the element has another attribute that has the same name as newAttr,
294       this function replaces that attribute and returns it; otherwise the
295       function returns a null attribute.
296
297       See also attributeNode(), setAttribute(), and setAttributeNodeNS().
298

QDomAttr QDomElement::setAttributeNodeNS ( const QDomAttr & newAttr )

300       Adds the attribute newAttr to this element.
301
302       If the element has another attribute that has the same local name and
303       namespace URI as newAttr, this function replaces that attribute and
304       returns it; otherwise the function returns a null attribute.
305
306       See also attributeNodeNS(), setAttributeNS(), and setAttributeNode().
307

void QDomElement::setTagName ( const QString & name )

309       Sets this element's tag name to name.
310
311       See also tagName().
312

QString QDomElement::tagName () const

314       Returns the tag name of this element. For an XML element like this:
315
316           <img src="myimg.png">
317       the tagname would return "img".
318
319       See also setTagName().
320

QString QDomElement::text () const

322       Returns the element's text or QString::null.
323
324       Example:
325
326           <h1>Hello <b>Qt</b> <![CDATA[<xml is cool>]]></h1>
327
328       The function text() of the QDomElement for the <h1> tag, will return
329       "Hello Qt <xml is cool>".
330
331       Comments are ignored by this function. It only evaluates QDomText and
332       QDomCDATASection objects.
333
334

SEE ALSO

336       http://doc.trolltech.com/qdomelement.html
337       http://www.trolltech.com/faq/tech.html
338
340       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
341       license file included in the distribution for a complete license
342       statement.
343

AUTHOR

345       Generated automatically from the source code.
346

BUGS

348       If you find a bug in Qt, please report it as described in
349       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
350       help you. Thank you.
351
352       The definitive Qt documentation is provided in HTML format; it is
353       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
354       web browser. This man page is provided as a convenience for those users
355       who prefer man pages, although this format is not officially supported
356       by Trolltech.
357
358       If you find errors in this manual page, please report them to qt-
359       bugs@trolltech.com.  Please include the name of the manual page
360       (qdomelement.3qt) and the Qt version (3.3.8).
361
362
363
364Trolltech AS                    2 February 2007               QDomElement(3qt)
Impressum