cxxtools::xml::XmlReader Class Reference

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

#include <cxxtools/xml/xmlreader.h>

Classes

class  Iterator

Public Member Functions

 XmlReader (std::istream &is, int flags=0)
 XmlReader (std::basic_istream< Char > &is, int flags=0)
 ~XmlReader ()
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

Detailed Description

Reads XML as a Stream of XML Nodes.

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

Constructor & Destructor Documentation

cxxtools::xml::XmlReader::XmlReader ( std::istream &  is,
int  flags = 0 
)
cxxtools::xml::XmlReader::XmlReader ( std::basic_istream< Char > &  is,
int  flags = 0 
)
cxxtools::xml::XmlReader::~XmlReader ( )

Member Function Documentation

bool cxxtools::xml::XmlReader::advance ( )
Iterator cxxtools::xml::XmlReader::current ( )
inline
size_t cxxtools::xml::XmlReader::depth ( ) const
const cxxtools::String& cxxtools::xml::XmlReader::documentEncoding ( ) const
const cxxtools::String& cxxtools::xml::XmlReader::documentVersion ( ) const
Iterator cxxtools::xml::XmlReader::end ( ) const
inline
EntityResolver& cxxtools::xml::XmlReader::entityResolver ( )
const EntityResolver& cxxtools::xml::XmlReader::entityResolver ( ) const
const Node& cxxtools::xml::XmlReader::get ( )

Get current element.

std::size_t cxxtools::xml::XmlReader::line ( ) const
const Node& cxxtools::xml::XmlReader::next ( )

Get next element from stream.

const StartElement& cxxtools::xml::XmlReader::nextElement ( )
const Node& cxxtools::xml::XmlReader::nextTag ( )
void cxxtools::xml::XmlReader::reset ( std::basic_istream< Char > &  is,
int  flags = 0 
)
void cxxtools::xml::XmlReader::reset ( std::istream &  is,
int  flags = 0 
)
bool cxxtools::xml::XmlReader::standaloneDocument ( ) const

The documentation for this class was generated from the following file: