Обзор
Примеры
Скриншоты
Сравнения
Приложения
Загрузить
Руководства
Базар
Статус и История
Частые вопросы (FAQ)
Авторы и лицензия
Форум
Помощь проекту
Поиск по сайту
Язык
русский













SourceForge.net Logo



Эта страница еще не переведена. Вы хотите перевести?

 

XmlNode - Hierarchical representation of XML

 

class XmlNode

This class represent the whole XML document as recursive hierarchic structure - each XmlNode can contain any number of child XmlNodes. XmlNode is mutable and U++ provides function to parse XML and store it to XmlNode and also to take XmlNode and create corresponding XML document.

 

 

Public Member List

 

static const XmlNode& Void()

Returns a constant reference to XmlNode representing "nothing". This reference is used as return value in cases where there are missing requested elements.

 


 

bool IsVoid() const

Returns true if XmlNode is Void.

 


 

int GetType() const

Returns the type of node. Possible types are: XML_PI, XML_DECL, XML_COMMENT, XML_DOC, XML_TEXT, XML_TAG.

 


 

String GetText() const

String GetTag() const

Returns the text associated with node. If the node is XML_TAG, the text is tag-id. If the node is XML_TEXT, the text is ... the text. In other cases, like XML_PI, the text is the copy of element content.

 


 

bool IsTag() const

Returns true if node is XML_TAG.

 


 

bool IsTag(const char *tagconst

Returns true if node is XML_TAG and is equal to tag.

 


 

bool IsText() const

Returns true if node is

 


 

void Clear()

Clears all content.

 


 

void CreateTag(const char *tag)

Sets this XmlNode to represent XML tag with id tag.

 


 

void CreateText(const String& txt)

Sets this XmlNode to represent text with content txt.

 


 

void CreatePI(const String& pi)

Sets this XmlNode to represent processing info pi.

 


 

void CreateDecl(const String& decl)

Sets this XmlNode to represent XML declaration decl.

 


 

void CreateComment(const String& comment)

Sets this XmlNode to represent XML comment.

 


 

void CreateDocument()

Set this XmlNode to be the top-level document node.

 


 

bool IsEmpty() const

Returns true if this XmlNode represents XML_DOC and contains no content.

 


 

operator bool() const

Same as !IsEmpty().

 


 

int GetCount() const

Returns a number of contained XmlNode sub-nodes.

 


 

XmlNode& At(int i)

Returns sub-node at index i. If there is no such node (number of sub-nodes is less than i + 1), number of nodes is extended to i + 1 with empty nodes.

 


 

const XmlNode& Node(int iconst

Returns node at index i. If there is none, behavior is undefined. This function is possibly slightly faster than either At or operator[].

 


 

const XmlNode& operator[](int iconst

Returns  i.

 


 

const XmlNode& operator[](const char *tagconst

Finds a XML_TAG sub-node with id tag and returns it. If no such node is found, returns Void().

 


 

XmlNode& Add()

Adds a new sub-node.

 


 

void AddText(const String& txt)

Adds a new text sub-node (XML_TEXT) and assigns it a text txt.

 


 

int FindTag(const char *tagconst

Finds a XML_TAG sub-node with id tag and returns its index. If no such sub-node exists, returns negative number.

 


 

XmlNode& Add(const char *tag)

Adds a new XML_TAG node with id tag and returns a reference to it.

 


 

XmlNode& GetAdd(const char *tag)

XmlNode& operator()(const char *tag)

Returns a reference to XML_TAG subnode with id tag. If no such node exists, adds it.

 


 

void Remove(const char *tag)

Removes XML_TAG sub-node with tag id. If there is no such sub-node, nothing happens.

 


 

String GatherText() const

String operator~() const

Concatenates all XML_TEXT sub-nodes in order of increasing indicies.

 


 

int GetAttrCount() const

Returns the number of attributes of current node (it has to be XML_TAG to have any attributes - nonzero returned).

 


 

String AttrId(int iconst

Returns id of attribute i.

 


 

String Attr(int iconst

Returns the value of attribute i.

 


 

String Attr(const char *idconst

Returns the value of attribute id. If no such attribute exists, returns empty String.

 


 

XmlNode& SetAttr(const char *id, const String& val)

Sets the attribute id to have value val. Attribute does not have exist yet.

 


 

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

Returns the value of attribute id converted to integer. If no such attribute exists, returns def.

 


 

XmlNode& SetAttr(const char *id, int val)

Sets the attribute id to have integer value val.

 


 

void SetAttrsPick(pick_ VectorMap<String, String>& a)

Replaces all attributes to a using pick operation (a is destroyed in operation).

 

 

Constructor detail

 

XmlNode()

Construct an empty XmlNode.

 

 

 

 

XmlNode - parser and output functions

 

XmlNode ParseXML(XmlParser& p, dword style = XML_IGNORE_DECLS|XML_IGNORE_PIS|XML_IGNORE_COMMENTS)

XmlNode ParseXML(const char *s, dword style = XML_IGNORE_DECLS|XML_IGNORE_PIS|XML_IGNORE_COMMENTS)

Creates XmlNode parsing XML document supplied either as string or XmlParser. style can be a combination of

 

XML_IGNORE_DECLS

Declaration elements are ignored.

XML_IGNORE_PIS

Processing info elements are ignored.

XML_IGNORE_COMMENTS

Comments are ignored.

 


 

String AsXML(const XmlNode& n, dword style = XML_HEADER|XML_DOCTYPE)

Creates a XML document from XmlNode n. style can be a combination

 

XML_HEADER

Adds standard XML header at the beginning of the document.

XML_DOCTYPE

Adds DOCTYPE declaration at the beginning of the document with type taken as id of first XML_TAG sub-node (which represents the root element).

 

 

Страница доступна на english языке. Вы хотите внести вклад?