#include <cxxtools/xml/xmlreader.h>
Public Member Functions | |
| XmlReader (std::istream &is, int flags=0) | |
| XmlReader (std::basic_istream< Char > &is, int flags=0) | |
| void | reset (std::basic_istream< Char > &is, int flags=0) |
| void | reset (std::istream &is, int flags=0) |
| const cxxtools::String & | documentVersion () const |
| const cxxtools::String & | documentEncoding () const |
| bool | standaloneDocument () const |
| EntityResolver & | entityResolver () |
| const EntityResolver & | entityResolver () const |
| size_t | depth () const |
| Iterator | current () |
| Iterator | end () const |
| const Node & | get () |
| Get current element. | |
| const Node & | next () |
| Get next element from stream. | |
| bool | advance () |
| const StartElement & | nextElement () |
| const Node & | nextTag () |
| std::size_t | line () const |
Classes | |
| class | Iterator |
The parser will only parse the XML document as far as the user read data from it. To read the current element (Node) the method get() can be used. To parse and read the next element the method next() can be used. Only when next() or any corresponding method or operator is called, the next chunk of XML input data is parsed.
To parse a XML-document, a XmlReader constructed with an input stream from which the XML document is to be read.
The current XML element (Node) can be read using get(). Every call to next() will parse the next element, position the cursor to the next element and return the parsed element. The returned element is of type Node, which is the super-class for all XML element classes. The class Node has a method type() which returns the type of the read element. Depending on the type the generic Node object may be cast to the more concrete element object. For example a Node object with a node type of Node::StartElement can be cast to StartElement.
Parsing using next() will continue until the end of the document is reached which will resultin a EndDocument element to be returned by next() and get().
This class also provides the method current() to obtain an iterator which basically works the same way like using using get() and next() directly. The iterator can be set to the next element by using the ++ operator. The current element can be accessed by dereferencing the iterator.