Qt 4.4: QXmlItem Class Reference

|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QXmlItem Class Reference
[QtXmlPatterns module]

The QXmlItem class represents an item in XQuery and XPath, which is either a node or an atomic value. More...

     #include <QXmlItem>

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.4.

- List of all members, including inherited members

### Public Types

- typedef Iterator

### Public Functions

- QXmlItem ()
- QXmlItem ( const QXmlItem & other )
- QXmlItem ( const QXmlNodeModelIndex & node )
- QXmlItem ( const QVariant & atomicValue )
- ~QXmlItem ()
- bool isAtomicValue () const
- bool isNode () const
- bool isNull () const
- QVariant toAtomicValue () const
- QXmlNodeModelIndex toNodeModelIndex () const
- QXmlItem & operator= ( const QXmlItem & other )

## Detailed Description

The QXmlItem class represents an item in XQuery and XPath, which is either a node or an atomic value.

In XQuery, all expressions evaluate to a sequence of items, where each item is an atomic value or a XML node. For instance, this query:

     <aNode/>,
     xs:base64Binary("FFFF"),
     current-date(),
     3e3, (: A floating point value :)
     attribute {"name"} {()}

evaluate to a sequence of five items: an element, an atomic value which is binary data encoded in base64, a date, a float, and an attribute node.

QXmlItem is the class that represents XQuery items in the Qt API. It is always either a node or an item, which isNode() and isAtomicValue() tells. Atomic values are represented in Qt using QVariant, and a QXmlitem can be converted to one by calling toAtomicValue(). Similarly, nodes are represented with QXmlNodeModelIndex, and those can be retrieved by calling toNodeModelIndex().

A default constructed QXmlItem instance is neither a node or an atomic value, it is `null`, as isNull() tells.

QXmlItem instances will dangle if the model that QXmlNodeModelIndex instances refers to is deleted.

## Member Type Documentation

### typedef QXmlItem::Iterator

A QAbstractXmlForwardIterator over QXmlItem.

## Member Function Documentation

### QXmlItem::QXmlItem ()

Construct a null QXmlItem, which is neither a node nor an atomic value.

For a default constructed QXmlItem, isNull() returns `true`.

### QXmlItem::QXmlItem ( const QXmlItem & other )

Constructs a QXmlItem instance that is a copy of other.

### QXmlItem::QXmlItem ( const QXmlNodeModelIndex & node )

Constructs a QXmlItem instance that is a copy of node. This item will subsequently be a node.

See also QXmlItem::isNode().

### QXmlItem::QXmlItem ( const QVariant & atomicValue )

Constructs a QXmlItem that is the atomic value atomicValue.

### QXmlItem::~QXmlItem ()

Destructs this QXmlItem instance.

### bool QXmlItem::isAtomicValue () const

Returns `true` if this item is an atomic value, otherwise `false`.

If this item is null, false is returned.

See also isNull() and isNode().

### bool QXmlItem::isNode () const

Returns `true` if this item is a Node, otherwise `false`.

If this item is null, false is returned.

See also isNull() and isAtomicValue().

### bool QXmlItem::isNull () const

Returns `true` if this QXmlItem instance do not represent an item.

### QVariant QXmlItem::toAtomicValue () const

Considers this item an atomic value, and returns it in the form of a QVariant instance.

If this QXmlItem is not an atomic value, the return value is a default constructed QVariant.

See also isAtomicValue().

### QXmlNodeModelIndex QXmlItem::toNodeModelIndex () const

Considers this item an node, and returns it in the form of a QXmlNodeModelIndex instance.

If this QXmlItem is not a node, the return value is undefined.

See also isNode().

### QXmlItem & QXmlItem::operator= ( const QXmlItem & other )

Assigns other to this QXmlItem instance.