QXmlResultItems

Inheritance diagram of QXmlResultItems

Synopsis

Functions

Detailed Description

The PySide.QtXmlPatterns.QXmlResultItems class iterates through the results of evaluating an XQuery in PySide.QtXmlPatterns.QXmlQuery .

PySide.QtXmlPatterns.QXmlResultItems presents the evaluation of an associated query as a sequence of QXmlItems . The sequence is traversed by repeatedly calling PySide.QtXmlPatterns.QXmlResultItems.next() , 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 PySide.QtXmlPatterns.QXmlResultItems.next() produce the sequence by lazy evaluation is that a query error can occur on any call to PySide.QtXmlPatterns.QXmlResultItems.next() . If an error occurs, both PySide.QtXmlPatterns.QXmlResultItems.next() and PySide.QtXmlPatterns.QXmlResultItems.current() will return the null PySide.QtXmlPatterns.QXmlItem , and PySide.QtXmlPatterns.QXmlResultItems.hasError() will return true.

PySide.QtXmlPatterns.QXmlResultItems can be thought of as an “iterator” that traverses the sequence of query results once, in the forward direction. Each call to PySide.QtXmlPatterns.QXmlResultItems.next() advances the iterator to the next PySide.QtXmlPatterns.QXmlItem in the sequence and returns it, and PySide.QtXmlPatterns.QXmlResultItems.current() always returns the PySide.QtXmlPatterns.QXmlItem that PySide.QtXmlPatterns.QXmlResultItems.next() returned the last time it was called.

Note

When using the PySide.QtXmlPatterns.QXmlResultItems overload of QXmlQuery.evaluateTo() 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.

class PySide.QtXmlPatterns.QXmlResultItems

Constructs an instance of PySide.QtXmlPatterns.QXmlResultItems .

PySide.QtXmlPatterns.QXmlResultItems.current()
Return type:PySide.QtXmlPatterns.QXmlItem

Returns the current item. The current item is the last item that was produced and returned by PySide.QtXmlPatterns.QXmlResultItems.next() .

Returns a null PySide.QtXmlPatterns.QXmlItem if there is no associated PySide.QtXmlPatterns.QXmlQuery .

PySide.QtXmlPatterns.QXmlResultItems.hasError()
Return type:PySide.QtCore.bool

If an error occurred during evaluation of the query, true is returned.

Returns false if query evaluation has been done.

PySide.QtXmlPatterns.QXmlResultItems.next()
Return type:PySide.QtXmlPatterns.QXmlItem

Returns the next result in the sequence produced by lazy evaluation of the associated query. When the returned PySide.QtXmlPatterns.QXmlItem is null, either the evaluation terminated normally without producing another result, or an error occurred. Call PySide.QtXmlPatterns.QXmlResultItems.hasError() to determine whether the null item was caused by normal termination or by an error.

Returns a null PySide.QtXmlPatterns.QXmlItem if there is no associated PySide.QtXmlPatterns.QXmlQuery .