xmlwrapp
Public Member Functions
xml::tree_parser Class Reference

The xml::tree_parser class is used to parse an XML document and generate a tree like structure of xml::node objects. More...

#include <tree_parser.h>

List of all members.

Public Member Functions

 tree_parser (const char *filename, bool allow_exceptions=true)
 xml::tree_parser class constructor.
 tree_parser (const char *data, size_type size, bool allow_exceptions=true)
 xml::tree_parser class constructor.
bool operator! () const
 Check to see if a xml::tree_parser class is vaild.
const std::string & get_error_message () const
 If operator! indicates that there was an error parsing your XML data, you can use this member function to get the error message that was generated during parsing.
bool had_warnings () const
 Check to see if there were any warnings from the parser while processing the given XML data.
xml::documentget_document ()
 Get a reference to the xml::document that was generated during the XML parsing.
const xml::documentget_document () const
 Get a const reference to the xml::document that was generate during the XML parsing.

Detailed Description

The xml::tree_parser class is used to parse an XML document and generate a tree like structure of xml::node objects.

After constructing a tree_parser, with either a file to parse or some in memory data to parse, you can walk the tree using the xml::node interface.


Constructor & Destructor Documentation

xml::tree_parser::tree_parser ( const char *  filename,
bool  allow_exceptions = true 
)

xml::tree_parser class constructor.

Given the name of a file, this constructor will parse that file.

There are two options for dealing with XML parsing errors. The default it to throw an exception (std::runtime_error). The other option is to pass false for the allow_exceptions flag. This will prevent an exception from being thrown, instead, a flag will be set that you can test with the operator! member function.

No matter what option you choose, this constructor may still throw exceptions for memory failure or other non-parsing related failures.

Parameters:
filenameThe name of the file to parse.
allow_exceptionsWhether or not you want an exception for parsing errors.
xml::tree_parser::tree_parser ( const char *  data,
size_type  size,
bool  allow_exceptions = true 
)

xml::tree_parser class constructor.

Given some data and the size of that data, parse that data as XML. To see if the data was parsed successfully use operator!.

Parameters:
dataThe XML data to parse.
sizeThe size of the XML data to parse.
allow_exceptionsWhether or not you want an exception for parsing errors.

Member Function Documentation

Get a reference to the xml::document that was generated during the XML parsing.

You should make sure to only use a reference to the document to avoid a deep copy.

Returns:
A reference to the xml::document.

Get a const reference to the xml::document that was generate during the XML parsing.

You should make sure to only use a reference to the document to avoid a deep copy.

Returns:
A const reference to the xml::document.
const std::string& xml::tree_parser::get_error_message ( ) const

If operator! indicates that there was an error parsing your XML data, you can use this member function to get the error message that was generated during parsing.

Returns:
The error message generated durring XML parsing.

Check to see if there were any warnings from the parser while processing the given XML data.

If there were, you may want to send the same document through xmllint or the event_parser to catch and review the warning messages.

Returns:
True if there were any warnings.
False if there were no warnings.

Check to see if a xml::tree_parser class is vaild.

That is, check to see if parsing XML data was successful and the tree_parser holds a good XML node tree.

Returns:
True if the tree_parser is NOT VAILD; false if it is vaild.

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