|  | Home · Overviews · Examples

# QXmlInputSource Class Reference
[com.trolltech.qt.xml module]

The `QXmlInputSource` class provides the input data for the `QXmlReader` subclasses. More...

## Detailed Description

The `QXmlInputSource` class provides the input data for the `QXmlReader` subclasses.

All subclasses of `QXmlReader` read the input XML document from this class.

This class recognizes the encoding of the data by reading the encoding declaration in the XML file if it finds one, and reading the data using the corresponding encoding. If it does not find an encoding declaration, then it assumes that the data is either in UTF-8 or UTF-16, depending on whether it can find a byte-order mark.

There are two ways to populate the input source with data: you can construct it with a `QIODevice`* so that the input source reads the data from that device. Or you can set the data explicitly with one of the `setData` functions.

Usually you either construct a `QXmlInputSource` that works on a `QIODevice`* or you construct an empty `QXmlInputSource` and set the data with `setData`. There are only rare occasions where you would want to mix both methods.

The `QXmlReader` subclasses use the `next` function to read the input character by character. If you want to start from the beginning again, use `reset`.

The functions `data` and `fetchData` are useful if you want to do something with the data other than parsing, e.g. displaying the raw XML file. The benefit of using the QXmlInputClass in such cases is that it tries to use the correct encoding.

See also `QXmlReader` and `QXmlSimpleReader`.