Informatii generale
Exemple
Imagini ecran
Comparatii
Aplicatii
Descarca
Documentation
Bazar
Statut si Foaie de parcurs
Intrebari frecvente
Autori si Licenta
Forum
Finantarea Ultimate++
Cauta in acest site
Limbă
română













SourceForge.net Logo



Aceasta pagina nu a fost inca tradusa. Doriti sa o traduceti?

 

XmlParser

 

class XmlParser

This class is a 'lexical' parser of XML. It is intended for implementation of descent parsers of XML.

 

 

Public Method List

 

void SkipWhites()

Skips any whitespaces in the input XML.

 


 

void RegisterEntity(const String& id, const String& text)

Registers a new XML entity id with value text.

 


 

bool IsEof()

Returns true if parser reached the end of text.

 


 

const char *GetPtr() const

Returns a pointer to the position in the text the parser reached.

 


 

bool IsTag()

Returns true if the parser is at XML start-tag.

 


 

String ReadTag()

Returns XML start-tag id and advances. If the parser is not at start-tag, XmlError is thrown.

 


 

bool Tag(const String& tag)

bool Tag(const char *tag)

If parser is at XML start-tag, advances and returns true, otherwise returns false.

 


 

void PassTag(const String& tag)

void PassTag(const char *tag)

If parser is at XML start-tag, advances, otherwise throws XmlError exception.

 


 

bool IsEnd()

Returns true if the parser is at matching end-tag. Note that encountering non-matching tags invokes XmlError, unless the parser is in relaxed mode.

 


 

bool End()

Returns true if the parser is at matching end-tag and advances. Note that encountering non-matching tags throws XmlError, unless the parser is in relaxed mode.

 


 

void PassEnd()

If parser is at matching end-tag, advances, otherwise XmlError is thrown.

 


 

bool TagE(const char *tag)

Calls Tag(tag) - if it returns true, immediately calls PassTag. In other words, matches element with empty content.

 


 

void PassTagE(const char *tag)

Calls PassTag(tag) and then PassEnd(). In other words, requires to advance over element with empty content.

 


 

int GetAttrCount() const

Returns the number of attributes of the last start-tag.

 


 

String GetAttr(int iconst

Returns the name of attribute i of the last start-tag.

 


 

String operator[](int iconst

Returns the value of attribute i of the last start-tag.

 


 

String operator[](const char *idconst

Returns the value of attribute with name id of the last start-tag. If no such attribute exists, return empty String (Null).

 


 

int Int(const char *id, int def = Null) const

Returns the value of attribute, converted to integer number, with the name id of the last start-tag. If no such attribute exists or if attribute text cannot be converted to integer, returns def.

 


 

double Double(const char *id, double def = Null) const

Returns the value of attribute, converted to floating point number, with the name id of the last start-tag. If no such attribute exists or if attribute text cannot be converted to integer, returns def.

 


 

bool IsText()

Returns true if parser is at text content of element.

 


 

String ReadText()

Reads a single text content. If there are contained elements in the content, parser stops at them. E.g. if parser is at "just a <b>test</b> foo", this method returns "just a ". If there is no text, returns empty String.

 


 

String ReadTextE()

Reads all text content until end-tag. If there are contained elements in the content, parser skips them. E.g. if parser is at "just a <b>test</b> foo", this method returns "just a foo". If there is no text, returns empty String.

 


 

bool IsDecl()

Returns true if parser is at XML declaration.

 


 

String ReadDecl()

Reads XML declaration - throws XmlError if parser is not at declaration.

 


 

bool IsPI()

Returns true if parser is at XML processing info.

 


 

String ReadPI()

Reads XML processing - throws XmlError if parser is not at any.

 


 

bool IsComment()

Returns true if parser is at XML comment.

 


 

String ReadComment()

Reads XML comment - throws XmlError if parser is not at any.

 


 

void Skip()

Skips current symbol. If the symbol is start-tag, skips everything until matching end-tag is passed.

 


 

void SkipEnd()

Skips everything past the end-tag of last parser start-tag.

 


 

VectorMap<String, StringPickAttrs() pick_

Picks all attributes of last passed start-tag. No attribute-related methods (including this one) can be called after this call until the next start-tag is processed.

 


 

int GetLine() const

Returns the current line of input text.

 


 

int GetColumn() const

Returns the current column of input text.

 


 

void Relaxed(bool b)

Activates the relaxed mode. In relaxed mode, XmlParser ignores mismatches of start-tag and end-tags. This mode was introduced to deal with broken XML files.

 

 

Constructor detail

 

XmlParser(const char *s)

Creates the parser for xml input text s. The pointed text must be valid through the whole parsing process (XmlParser does not make copy of the text).

 

 

Aceasta pagina este deasemenea in english. Doriti sa contribuiti?