CMarkup是优秀操作XML数据的C++类,处理速度相当的快。
而且相对简洁很多。
基本接口如下:
来自CMarkup的官网http://www.firstobject.com/dn_markup.htm
Initialization
| Load | Populates the CMarkup object from a file and parses it |
| SetDoc | Populates the CMarkup object from a string and parses it |
Output
| Save | Writes the document to file |
| GetDoc | Returns the whole document as a markup string |
| GetDocFormatted | Returns the formatted markup string of the whole document |
File mode
| Open | Opens file, initiating file mode for read or write (and append is a special case of write mode) |
| Close | Closes file and ends file mode |
| Flush | For file write mode, this flushes any partial document in memory (up to the closing tags) and the file stream itself |
Changing the current position
| FindElem | Locates next element, optionally matching tag name or path |
| FindChildElem | Locates next child element matching tag name or path |
| FindPrevElem | Locates previous element, optionally matching tag name |
| FindPrevChildElem | Locates previous child element, optionally matching tag name |
| FindNode | Locates next node, optionally matching node type(s) |
| IntoElem | Go "into" current main position element such that it becomes the current parent position |
| OutOfElem | Makes the current parent position into the current main position |
| ResetPos | Resets the current position to the start of the document |
| ResetMainPos | Resets the current main position to before the first sibling |
| ResetChildPos | Resets the current child position to before the first child |
Adding to the Document
| AddElem | Adds an element after the current main position element or last sibling |
| InsertElem | Inserts an element before the current main position element or first sibling |
| AddChildElem | Adds an element after the current child position element or last child |
| InsertChildElem | Inserts an element before the current child position element or first child |
| AddSubDoc | Adds a subdocument after the current main position element or last sibling |
| InsertSubDoc | Inserts a subdocument before the current main position element or first sibling |
| AddChildSubDoc | Adds a subdocument after the current child position element or last child |
| InsertChildSubDoc | Inserts a subdocument before the current child position element or first child |
| AddNode | Adds a node after the current node or at the end of the parent element content |
| InsertNode | inserts a node before the current node or at the beginning of the parent element content |
Removing from the Document
| RemoveElem | Removes the current main position element including child elements |
| RemoveChildElem | Removes the current child position element including its child elements |
| RemoveNode | Removes the current node |
| RemoveAttrib | Removes the specified attribute from the current main position element |
| RemoveChildAttrib | Removes the specified attribute from the current child position element |
Getting Values
| GetData | Returns the string value of the current main position element or node |
| GetChildData | Returns the string value of the current child position element |
| GetElemContent | Returns the string markup content of the current main position element including child elements |
| GetSubDoc | Returns the subdocument markup string of the current main position element including child elements |
| GetChildSubDoc | Returns the subdocument markup string of the current child position element including child elements |
| GetAttrib | Returns the string value of the specified attribute of the main position element (or processing instruction) |
| GetChildAttrib | Returns the string value of the specified attribute of the child position element |
| HasAttrib | Returns true if the specified attribute exists in the main position element (or processing instruction) |
| HasChildAttrib | Returns true if the specified attribute exists in the child position element |
| GetTagName | Returns the tag name of the main position element (or processing instruction) |
| GetChildTagName | Returns the tag name of the child position element |
| FindGetData | Locates the next element matching the specified path and returns the string value |
Setting Values
| SetData | Sets the value of the current main position element or node |
| SetChildData | Sets the value of the current child position element |
| SetElemContent | Sets the markup content of the current main position element |
| SetAttrib | Sets the value of the specified attribute of the current main position element (or processing instruction) |
| SetChildAttrib | Sets the value of the specified attribute of the current child position element |
| FindSetData | Locates the next element matching the specified path and sets the value |
Other Info
| GetAttribName | Returns the name of attribute specified by number for the current main position element |
| GetNodeType | Returns the node type of the current node |
| GetElemLevel | Returns the level of the current main position |
| GetElemFlags | Returns the current main position element's flags |
| SetElemFlags | Sets the current main position element's flags |
| GetOffsets | Obtains the document text offsets of the current main position |
| GetAttribOffsets | Obtains the document text offsets of the specified attribute in the current main position |
Remembering positions
| SavePos | Saves the current position with an optional string name using a hash map |
| RestorePos | Goes to the position saved with |
| SetMapSize | Sets the size of a map for use with the |
| GetElemIndex | Returns the integer index of the current main position element |
| GotoElemIndex | Sets the current main position element to that of the given integer index |
| GetChildElemIndex | Returns the integer index of the current child position element |
| GotoChildElemIndex | Sets the current child position element to that of the given integer index |
| GetParentElemIndex | Returns the integer index of the current parent position element |
| GotoParentElemIndex | Sets the current parent position element to that of the given integer index |
| GetElemPath | Returns a string representing the absolute path of the main position element |
| GetChildElemPath | Returns a string representing the absolute path of the child position element |
| GetParentElemPath | Returns a string representing the absolute path of the parent position element |
Document Status
| IsWellFormed | Determines if document has a single root element and properly contained elements |
| GetResult | Returns result markup from last parse or file operation |
| GetError | Returns English error/result synopsis string from last parse or file operation |
| GetDocFlags | Returns the document flags |
| SetDocFlags | Sets the document flags |
| GetDocElemCount | Returns the number of elements in the document |
Static Utility Functions
| ReadTextFile | Reads a text file into a string |
| WriteTextFile | Writes a string to a text file |
| GetDeclaredEncoding | Returns the encoding name as a string from the XML declaration |
| EscapeText | Returns the string with special characters encoded for markup |
| Text | Returns the string with special characters unencoded for a string value |
| UTF8ToA | Converts a UTF-8 string to a non-Unicode ("ANSI") string |
| AToUTF8 | Converts a non-Unicode ("ANSI") string to UTF-8 |
| UTF16To8 | Converts a UTF-16 string to UTF-8 |
| UTF8To16 | Converts a UTF-8 string to UTF-16 |
| EncodeBase64 | Encodes a binary da |
| DecodeBase64 | Encodes a Base64 string to a binary da |
353

被折叠的 条评论
为什么被折叠?



