libxml++  2.36.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
xmlpp::DomParser Class Reference

DOM XML parser. More...

#include <libxml++/parsers/domparser.h>

Inheritance diagram for xmlpp::DomParser:
Inheritance graph
[legend]
Collaboration diagram for xmlpp::DomParser:
Collaboration graph
[legend]

Public Member Functions

 DomParser ()
 Create a parser with an empty document.
 DomParser (const Glib::ustring& filename, bool validate=false)
 Instantiate the parser and parse a document immediately.
virtual ~DomParser ()
virtual void parse_file (const Glib::ustring& filename)
 Parse an XML document from a file.
virtual void parse_memory (const Glib::ustring& contents)
 Parse an XML document from a string.
void parse_memory_raw (const unsigned char* contents, size_type bytes_count)
 Parse an XML document from raw memory.
virtual void parse_stream (std::istream& in)
 Parse an XML document from a stream.
 operator bool () const
 Test whether a document has been parsed.
Documentget_document ()
 Get the parsed document.
const Documentget_document () const
 Get the parsed document.
- Public Member Functions inherited from xmlpp::Parser
 Parser ()
virtual ~Parser ()
virtual void set_validate (bool val=true)
 By default, the parser will not validate the XML file.
virtual bool get_validate () const
 See set_validate()
virtual void set_substitute_entities (bool val=true)
 Set whether the parser will automatically substitute entity references with the text of the entities' definitions.
virtual bool get_substitute_entities () const
 See set_substitute_entities().
void set_throw_messages (bool val=true)
 Set whether the parser will collect and throw error and warning messages.
bool get_throw_messages () const
 See set_throw_messages().

Protected Member Functions

virtual void parse_context ()
virtual void release_underlying ()
- Protected Member Functions inherited from xmlpp::Parser
virtual void initialize_context ()
virtual void on_validity_error (const Glib::ustring& message)
virtual void on_validity_warning (const Glib::ustring& message)
virtual void handleException (const exception& e)
virtual void check_for_exception ()
virtual void check_for_validity_messages ()

Protected Attributes

Documentdoc_
- Protected Attributes inherited from xmlpp::Parser
_xmlParserCtxt* context_
exceptionexception_
Glib::ustring validate_error_
Glib::ustring validate_warning_
bool validate_
bool substitute_entities_

Additional Inherited Members

- Public Types inherited from xmlpp::Parser
typedef unsigned int size_type
- Protected Types inherited from xmlpp::Parser
enum  MsgType {
  MsgParserError,
  MsgParserWarning,
  MsgValidityError,
  MsgValidityWarning
}
- Static Protected Member Functions inherited from xmlpp::Parser
static void callback_parser_error (void* ctx, const char* msg,...)
static void callback_parser_warning (void* ctx, const char* msg,...)
static void callback_validity_error (void* ctx, const char* msg,...)
static void callback_validity_warning (void* ctx, const char* msg,...)
static void callback_error_or_warning (MsgType msg_type, void* ctx, const char* msg, va_list var_args)

Detailed Description

DOM XML parser.

Constructor & Destructor Documentation

xmlpp::DomParser::DomParser ( )

Create a parser with an empty document.

Exceptions
xmlpp::internal_errorIf an empty document can't be created.
xmlpp::DomParser::DomParser ( const Glib::ustring &  filename,
bool  validate = false 
)
explicit

Instantiate the parser and parse a document immediately.

Parameters
filenameThe path to the file.
validateWhether the parser should validate the XML.
Exceptions
xmlpp::internal_error
xmlpp::parse_error
xmlpp::validity_error
virtual xmlpp::DomParser::~DomParser ( )
virtual

Member Function Documentation

Document* xmlpp::DomParser::get_document ( )

Get the parsed document.

Returns
A pointer to the parsed document, or 0.
const Document* xmlpp::DomParser::get_document ( ) const

Get the parsed document.

Returns
A pointer to the parsed document, or 0.
xmlpp::DomParser::operator bool ( ) const

Test whether a document has been parsed.

virtual void xmlpp::DomParser::parse_context ( )
protectedvirtual
virtual void xmlpp::DomParser::parse_file ( const Glib::ustring &  filename)
virtual

Parse an XML document from a file.

If the parser already contains a document, that document and all its nodes are deleted.

Parameters
filenameThe path to the file.
Exceptions
xmlpp::internal_error
xmlpp::parse_error
xmlpp::validity_error

Implements xmlpp::Parser.

virtual void xmlpp::DomParser::parse_memory ( const Glib::ustring &  contents)
virtual

Parse an XML document from a string.

If the parser already contains a document, that document and all its nodes are deleted.

Parameters
contentsThe XML document as a string.
Exceptions
xmlpp::internal_error
xmlpp::parse_error
xmlpp::validity_error

Implements xmlpp::Parser.

void xmlpp::DomParser::parse_memory_raw ( const unsigned char *  contents,
size_type  bytes_count 
)

Parse an XML document from raw memory.

If the parser already contains a document, that document and all its nodes are deleted.

Parameters
contentsThe XML document as an array of bytes.
bytes_countThe number of bytes in the contents array.
Exceptions
xmlpp::internal_error
xmlpp::parse_error
xmlpp::validity_error
virtual void xmlpp::DomParser::parse_stream ( std::istream &  in)
virtual

Parse an XML document from a stream.

If the parser already contains a document, that document and all its nodes are deleted.

Parameters
inThe stream.
Exceptions
xmlpp::internal_error
xmlpp::parse_error
xmlpp::validity_error

Implements xmlpp::Parser.

virtual void xmlpp::DomParser::release_underlying ( )
protectedvirtual

Reimplemented from xmlpp::Parser.

Member Data Documentation

Document* xmlpp::DomParser::doc_
protected

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