Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

XmlReader Class Reference

Reads XML as a Stream of XML Nodes. More...

#include <cxxtools/xml/xmlreader.h>

List of all members.

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::StringdocumentVersion () const
const cxxtools::StringdocumentEncoding () const
bool standaloneDocument () const
EntityResolverentityResolver ()
const EntityResolverentityResolver () const
size_t depth () const
Iterator current ()
Iterator end () const
const Nodeget ()
 Get current element.
const Nodenext ()
 Get next element from stream.
bool advance ()
const StartElementnextElement ()
const NodenextTag ()
std::size_t line () const

Classes

class  Iterator


Detailed Description

This class operates on an input stream from which XML character data is read and parsed.

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.

See also:
Node
Copyright © 2008 The Tntnet Development Team
Tntnet 1.6