ubit::UXmlParser Class Reference

XML parser. More...

#include <uxmlparser.hpp>

Inheritance diagram for ubit::UXmlParser:

ubit::UHtmlParser List of all members.

Public Member Functions

 UXmlParser ()
 creates a new XML parser.
void addGrammar (const UXmlGrammar &)
 adds a grammar to the parser.
void setPermissive (bool b)
 parses documents in permissive mode (default is false).
void setCollapseSpaces (bool b)
 collapses whitespaces (and tabs and newlines) in elements (default is false).
UXmlDocread (const UStr &pathname)
 reads and parses a XML file and returns the corresponding XML tree.
UXmlDocparse (const UStr &doc_name, const UStr &doc_text)
 reads and parses a XML buffer and returns the corresponding XML tree.
int getStatus ()
 returns the reading/parsing status.
void setErrorOutput (UStr &error_buffer)
 specifies that errors are written in this buffer.
void setErrorOutput (std::ostream &)
 specifies that errors are written on this stream (eg. std::cout).

Protected Member Functions

void readElement (UGroup *parent)
void readText (UGroup *parent)
bool readXMLDeclaration ()
void readXMLInstruction (UGroup *parent)
void readSGMLData (UGroup *parent)
void skipSpaces ()
UChar readCharEntityReference ()
bool readName (UStr &)
bool readQuotedValue (UStr &, UChar quoting_char)
bool readUnquotedValue (UStr &)
bool readNameValuePair (UStr &name, UStr &value)
UGroupreadElementStartTag (UStr &elem_name, int &stat)
int readElementEndTag (const UStr &elem_name)
void error (const char *msg, const UChar *line)
void error (const char *msg_start, const UStr &name, const char *msg_end, const UChar *line)
void unexpected (const char *msg, const UChar *line)

Detailed Description

XML parser.

See also:
: use UHtmlParser to parse HTML code (and see and setPermissive() and setCollapseSpaces() for more details)


Member Function Documentation

void ubit::UXmlParser::addGrammar ( const UXmlGrammar  ) 

adds a grammar to the parser.

note that order matters: an element or an attribute name is searched in the first grammar, then is the second one, and so on.

UXmlDoc * ubit::UXmlParser::parse ( const UStr doc_name,
const UStr doc_text 
)

reads and parses a XML buffer and returns the corresponding XML tree.

'doc_text' is a string that contains the text to parse. 'doc_name' is the name of this document

UXmlDoc * ubit::UXmlParser::read ( const UStr pathname  ) 

reads and parses a XML file and returns the corresponding XML tree.

'pathname' is the qualified filename of the XML document.

void ubit::UXmlParser::setCollapseSpaces ( bool  b  ) 

collapses whitespaces (and tabs and newlines) in elements (default is false).

should be set to false when parsing actual XML code, and true for HTML code. Note that whitespaces are never collapsed for elements which UElementClass

void ubit::UXmlParser::setPermissive ( bool  b  ) 

parses documents in permissive mode (default is false).

allows for constructs which are invalid in XML code but OK in HTML code:


The documentation for this class was generated from the following files:
Generated on Mon Jan 29 00:20:58 2007 for Ubit by  doxygen 1.4.7