Home | Modules | Class Hierarchy | Alphabetical List | Compound List | Related Pages

# CXmlEl Class Reference
[XML Parser]

Inheritance diagram for CXmlEl:

## Detailed Description

Simple XML Parser implementaion.

Features:
  1. Unicode support. According to the w3c Recommendations, this parser supports most Unicode character encodings. They are detected in next order:
     - Through the byte order mark (U+FEFF) or sequence "<?". UTF-8, UTF-16 (LE and BE), UTF-32 (LE and BE) charsets are detected in this way.
     - With "charset" parameter in xml declaration PI: samples:
       - <?xml charset="UTF-8"?>
       - <?xml charset="cp1251"?> Only UTF-8 and ANSI codepages are detected with this rule. All ANSI codepages are come from Colorer Unicode support classes.
     - Explicit ANSI codepage information from application, wich uses parser, with CXmlEl::parse() method.
     - In case of unavailable charset information, UTF-8 encoding is used.

  2. Entities and References parsing.
     - Simple Character References:
       - &#x0431;
       - &#32;
     - According to the w3c Predefined Entities, next DTD is used implicitly:
       - <!ENTITY lt "&#38;#60;">
       - <!ENTITY gt "&#62;">
       - <!ENTITY amp "&#38;#38;">
       - <!ENTITY apos "&#39;">
       - <!ENTITY quot "&#34;">

  3. W3C CDATA section are supported:
     - <![CDATA[ This is an <unescaped> data ]]>

Dislikes:
  1. This parser doesn't conform w3c Recommendations. It is neither well-forming nor validating parser. So, it can parse any HTML-like code.

  2. Parser treats comment nodes as simple text nodes According to this, all entities and char references in comments would be replaced.

  3. All PI nodes are treated as simple element nodes with names "?PIName" and parameters.

  4. Parser allows any non-Whitespace characters in node and parameter names. It doesn't checks character class in document. At all, any stream of bytes would be transformed into some kind of tree.

## Public Methods
bool | parse (const byte *src, int sz, const char *codepage=0)
| Base parse method.
virtual CXmlEl * | parent ()
| Gets element's parent node.
virtual CXmlEl * | next ()
| Gets element's following sibling node.
virtual CXmlEl * | prev ()
| Gets element's preceding sibling node.
virtual CXmlEl * | child ()
| Gets element's first child node.
ElType | getType ()
| Current element's type.
const String * | getName ()
| Gets element's name.
const String * | getContent ()
| Gets content of character data nodes.
int | getParamCount ()
| Gets element's number of parameters.
const String * | getParamName (int no)
| Returns name of parameter with index `no.`
const String * | getParamValue (int no)
| Returns value of parameter with index `no.`
const String * | getParamValue (const String &par)
| Returns parameter's value by name.
bool | getParamValue (const String &par, int *result)
| Returns integer parameter's value.
bool | getParamValue (const String &par, double *result)
| Returns double parameter's value.
CXmlEl * | search (const String &tagname)
| Searches for `tagname` element.
CXmlEl * | enumChildred (int no)
| Enumerates element's childred by `no` index.
virtual CXmlEl * | fPrev ()
| Moving in full tree hierarchy.
virtual CXmlEl * | fNext ()
| Moving in full tree hierarchy.
virtual CXmlEl * | fFirst ()
| Moving in full tree hierarchy.
virtual CXmlEl * | fLast ()
| Moving in full tree hierarchy.
## Protected Methods
virtual bool | init ()
| for derived classes
virtual CXmlEl * | createNew (ElType type, CXmlEl *parent, CXmlEl *after)
| for derived classes
void | destroyLevel ()
| Recursive object cleanup.
void | insert (CXmlEl *El)
## Protected Attributes
String * | content
String * | name
CXmlEl * | eparent
CXmlEl * | enext
CXmlEl * | eprev
CXmlEl * | echild
int | chnum
ElType | type
Hashtable< const String * > | params

## Member Function Documentation

bool CXmlEl::parse | ( | const byte * | src,
|  | int | sz,
|  | const char * | codepage = 0
| ) |

  | Base parse method. constructs XML tree from `src` byte stream. Object, for which this method was called, becomes root of new XML tree. All created xml elements accessible from it's next() element. Parameters:
  src | Byte stream of xml source.
  sz | Size of input source in bytes.
  codepage | Default codepage to use.

CXmlEl * CXmlEl::search | ( | const String & | tagname | ) |

| Searches for `tagname` element. Deprecated: Old unused method.

Colorer-take5 Library. Copyright © 1999-2003 Cail Lomecb.
Generated at Fri Sep 12 18:54:55 2003 by doxygen 1.3-rc2.