QXmlResultItems¶
The
QXmlResultItems
class iterates through the results of evaluating an XQuery inQXmlQuery
. More…
Synopsis¶
Functions¶
Detailed Description¶
QXmlResultItems
presents the evaluation of an associated query as a sequence ofQXmlItems
. The sequence is traversed by repeatedly callingnext()
, which actually produces the sequence by lazy evaluation of the query.QXmlQuery query; query.setQuery("<e/>, 1, 'two'"); QXmlResultItems result; if (query.isValid()) { query.evaluateTo(&result); QXmlItem item(result.next()); while (!item.isNull()) { // use item item = result.next(); } if (result.hasError()) /* Runtime error! */; }An effect of letting
next()
produce the sequence by lazy evaluation is that a query error can occur on any call tonext()
. If an error occurs, bothnext()
andcurrent()
will return the nullQXmlItem
, andhasError()
will return true.
QXmlResultItems
can be thought of as an “iterator” that traverses the sequence of query results once, in the forward direction. Each call tonext()
advances the iterator to the nextQXmlItem
in the sequence and returns it, andcurrent()
always returns theQXmlItem
thatnext()
returned the last time it was called.Note
When using the
QXmlResultItems
overload ofevaluateTo()
to execute a query, it is advisable to create a new instance of this class for each new set of results rather than reusing an old instance.See also
- class PySide2.QtXmlPatterns.QXmlResultItems¶
Constructs an instance of
QXmlResultItems
.
- PySide2.QtXmlPatterns.QXmlResultItems.current()¶
- Return type:
Returns the current item. The current item is the last item that was produced and returned by
next()
.Returns a null
QXmlItem
if there is no associatedQXmlQuery
.
- PySide2.QtXmlPatterns.QXmlResultItems.hasError()¶
- Return type:
bool
If an error occurred during evaluation of the query, true is returned.
Returns false if query evaluation has been done.
- PySide2.QtXmlPatterns.QXmlResultItems.next()¶
- Return type:
Returns the next result in the sequence produced by lazy evaluation of the associated query. When the returned
QXmlItem
is null, either the evaluation terminated normally without producing another result, or an error occurred. CallhasError()
to determine whether the null item was caused by normal termination or by an error.Returns a null
QXmlItem
if there is no associatedQXmlQuery
.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.