CkXml C++ Reference Documentation

CkXml

A free non-validating XML parser component with encryption and compression features.

Properties

bool get_Cdata(void);
void put_Cdata(bool newVal);

When True, causes an XML node's content to be encapsulated in a CDATA section.

(C++) Using CDATA in XML

(MFC) Using CDATA in XML

void get_Content(CkString &str);
const char *content(void);
void put_Content(const char *ansiOrUtf8Str);

The content of the XML node. It is the text between the open and close tags, not including child nodes. For example:

<tag1>This is the content</tag1>

<tag2><child1>abc</child1><child2>abc</child2>This is the content</tag2>
Because the child nodes are not included, the content of "tag1" and "tag2" are both equal to "This is the content".

Content vs. Children: A common misconception explained.

(C++) Setting XML Tag and Content

(MFC) Setting XML Tag and Content

int get_ContentInt(void);
void put_ContentInt(int newVal);

Set/get the content as an integer.

void get_DebugLogFilePath(CkString &str);
const char *debugLogFilePath(void);
void put_DebugLogFilePath(const char *ansiOrUtf8Str);

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:

  1. a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
  2. the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
  3. there is an internal problem (bug) in the Chilkat code that causes the hang.

void get_DocType(CkString &str);
const char *docType(void);
void put_DocType(const char *ansiOrUtf8Str);

The DOCTYPE declaration (if any) for the XML document.

(C++) Setting the XML DOCTYPE

(MFC) Setting the XML DOCTYPE

bool get_EmitBom(void);
void put_EmitBom(bool newVal);

Introduced in version 9.5.0.44

If true, then emit the BOM (byte order mark, also known as a preamble) for encodings such as utf-8, utf-16, etc. The defautl value is false. This only applies when writing XML files. It does not apply when getting the XML as a string via the GetXml method.

bool get_EmitCompact(void);
void put_EmitCompact(bool newVal);

Introduced in version 9.5.0.64

If true, then GetXml and GetXmlSb emit compact XML. The XML emitted has no unnecessary whitespace, incuding no end-of-lines (CR's and/or LF's). The default value is false, which maintains backward compatibility.

(C++) XML EmitCompact

(MFC) XML EmitCompact

bool get_EmitXmlDecl(void);
void put_EmitXmlDecl(bool newVal);

If true, then the XML declaration is emitted for methods (such as GetXml or SaveXml) where the XML is written to a file or string. The default value of this property is true. If set to false, the XML declaration is not emitted. (The XML declaration is the 1st line of an XML document starting with "<?xml ...".

void get_Encoding(CkString &str);
const char *encoding(void);
void put_Encoding(const char *ansiOrUtf8Str);

This is the encoding attribute in the XML declaration, such as "utf-8" or "iso-8859-1". The default is "utf-8". This property can be set from any node in the XML document and when set, causes the encoding property to be added to the XML declaration. Setting this property does not cause the document to be converted to a different encoding.

Calling any of the LoadXml* methods causes this property to be set to the charset found within the XML, if any. If no charset is specified within the loaded XML, then the LoadXml method resets this property to its default value of "utf-8".

int get_I(void);
void put_I(int newVal);

Introduced in version 9.5.0.64

Used in tagPaths (and ChilkatPath). The value of this property is substituted for "i" in "[i]". See the example below..

(C++) Demonstrate the XML "I" Property

(MFC) Demonstrate the XML "I" Property

(C++) Demonstrate the XML I, J, and K Properties

(MFC) Demonstrate the XML I, J, and K Properties

int get_J(void);
void put_J(int newVal);

Introduced in version 9.5.0.64

Used in tagPaths (and ChilkatPath). The value of this property is substituted for "j" in "[j]". See the example below..

(C++) Demonstrate the XML I, J, and K Properties

(MFC) Demonstrate the XML I, J, and K Properties

int get_K(void);
void put_K(int newVal);

Introduced in version 9.5.0.64

Used in tagPaths (and ChilkatPath). The value of this property is substituted for "k" in "[k]". See the example below..

void get_LastErrorHtml(CkString &str);
const char *lastErrorHtml(void);

Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

void get_LastErrorText(CkString &str);
const char *lastErrorText(void);

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

Concept of LastErrorText

LastErrorText Standard Information

void get_LastErrorXml(CkString &str);
const char *lastErrorXml(void);

Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

bool get_LastMethodSuccess(void);
void put_LastMethodSuccess(bool newVal);

Introduced in version 9.5.0.52

Indicate whether the last method call succeeded or failed. A value of true indicates success, a value of false indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

  • Any method that returns a string.
  • Any method returning a Chilkat object, binary bytes, or a date/time.
  • Any method returning a standard boolean status value where success = true and failure = false.
  • Any method returning an integer where failure is defined by a return value less than zero.

Note: Methods that do not fit the above requirements will always set this property equal to true. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.

int get_NumAttributes(void);

The number of attributes. For example, the following node has 2 attributes:

<tag attr1="value1" attr2="value2"> This is the content</tag>

(C++) Methods for Getting Attributes

(MFC) Methods for Getting Attributes

int get_NumChildren(void);

The number of direct child nodes contained under this XML node.

bool get_SortCaseInsensitive(void);
void put_SortCaseInsensitive(bool newVal);

If true (or 1 for ActiveX), then all Sort* methods use case insensitive sorting.

bool get_Standalone(void);
void put_Standalone(bool newVal);

This is the standalone attribute in the XML declaration. This property can be set from any node in the XML document. A value of true adds a standalone="yes" to the XML declaration:

<?xml ... standalone="yes">

void get_Tag(CkString &str);
const char *tag(void);
void put_Tag(const char *ansiOrUtf8Str);

The XML node's tag.

(C++) Setting XML Tag and Content

(MFC) Setting XML Tag and Content

int get_TreeId(void);

Each tree (or XML document) has a unique TreeId. This is the ID of the tree, and can be used to determine if two Xml objects belong to the same tree.

bool get_Utf8(void);
void put_Utf8(bool newVal);

When set to true, all "const char *" arguments are interpreted as utf-8 strings. If set to false (the default), then "const char *" arguments are interpreted as ANSI strings. Also, when set to true, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to false, all "const char *" return values are ANSI strings.

bool get_VerboseLogging(void);
void put_VerboseLogging(bool newVal);

If set to true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is false. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

void get_Version(CkString &str);
const char *version(void);

Version of the component/library, such as "9.5.0.63"

Methods

bool AccumulateTagContent(const char *tag, const char *skipTags, CkString &outStr);
const char *accumulateTagContent(const char *tag, const char *skipTags);

Accumulates the content of all nodes having a specific tag into a single result string. SkipTags specifies a set of subtrees to be avoided. The skipTags are formatted as a string of tags delimited by vertical bar characters. All nodes in sub-trees rooted with a tag appearing in skipTags are not included in the result.

Returns true for success, false for failure.

(C++) XML Accumulate Tag Content

(MFC) XML Accumulate Tag Content

bool AddAttribute(const char *name, const char *value);

Adds an attribute to the calling node in the XML document. Returns True for success, and False for failure.

Returns true for success, false for failure.

(C++) Adding Attributes to an XML Node

(MFC) Adding Attributes to an XML Node

(C++) AddAttribute - Insert New Attribute in XML Node

(MFC) AddAttribute - Insert New Attribute in XML Node

bool AddAttributeInt(const char *name, int value);

Adds an integer attribute to a node.

Returns true for success, false for failure.

bool AddChildTree(CkXml &tree);

Adds an entire subtree as a child. If the child was a subtree within another Xml document then the subtree is effectively transferred from one XML document to another.

Returns true for success, false for failure.

void AddOrUpdateAttribute(const char *name, const char *value);

Adds an attribute to an XML node. If an attribute having the specified name already exists, the value is updated.

(C++) Update an XML Attribute

(MFC) Update an XML Attribute

void AddOrUpdateAttributeI(const char *name, int value);

Adds an integer attribute to an XML node. If an attribute having the specified name already exists, the value is updated.

void AddStyleSheet(const char *styleSheet);

Adds a style sheet declaration to the XML document. The styleSheet should be a string such as:

<?xml-stylesheet href="mystyle.css" title="Compact" type="text/css"?>

void AddToAttribute(const char *name, int amount);

Adds an integer amount to an integer attribute's value. If the attribute does not yet exist, this method behaves the same as AddOrUpdateAttributeI.

(C++) Update an XML Attribute

(MFC) Update an XML Attribute

void AddToChildContent(const char *tag, int amount);

Adds an integer value to the content of a child node.

void AddToContent(int amount);

Adds an integer amount to the node's content.

bool AppendToContent(const char *str);

Appends text to the content of an XML node

Returns true for success, false for failure.

bool BEncodeContent(const char *charset, CkByteData &inData);

Sets the node's content with 8bit data that is in a specified multibyte character encoding such as utf-8, shift-jis, big5, etc. The data is first B-encoded and the content is set to be the B-encoded string. For example, if called with "Big5"for the charset, you would get a string that looks something like this: "=?Big5?B?pHCtsw==?=". The data is Base64-encoded and stored between the last pair of "?" delimiters. Use the DecodeContent method to retrieve the byte data from a B encoded string.

Returns true for success, false for failure.

bool ChildContentMatches(const char *tagPath, const char *pattern, bool caseSensitive);

Return true if a child at the specified tagPath contains content that matches a wildcarded pattern. Otherwise returns false.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

bool ChilkatPath(const char *pathCmd, CkString &outStr);
const char *chilkatPath(const char *pathCmd);

Follows a series of commands to navigate through an XML document to return a piece of data or update the caller's reference to a new XML document node.

Note: This method not related to the XPath (XML Path) standard in any way.

The pathCmd is formatted as a series of commands separated by vertical bar characters, and terminated with a return-command:

    command|command|command|...|returnCommand

A command can be any of the following:

  1. TagName -- Navigate to the 1st direct child with the given tag.
  2. TagName[n] -- Navigate to the Nth direct child with the given tag.
  3. .. -- Navigate up to the parent
  4. TagName{Content} -- Navigate to the 1st direct child with the given tag having the exact content.
  5. /T/TagName -- Traverse the XML DOM tree (rooted at the caller) and navigate to the 1st node having the given tag.
  6. /C/TagName,ContentPattern -- Traverse the XML DOM tree (rooted at the caller) and navigate to the 1st node having the given tag with content that matches the ContentPattern. ContentPattern may use one or more asterisk ('*") characters to represent 0 or more of any character.
  7. /C/ContentPattern -- Traverse the XML DOM tree (rooted at the caller) and navigate to the 1st node having any tag with content that matches the ContentPattern. ContentPattern may use one or more asterisk ('*") characters to represent 0 or more of any character.
  8. /A/TagName,AttrName,AttrValuePattern -- Traverse the XML DOM tree (rooted at the caller) and navigate to the 1st node having the given tag, and attribute, with the attribute value that matches the AttrValuePattern. AttrValuePattern may use one or more asterisk ('*") characters to represent 0 or more of any character.
The returnCommand can be any of the following:
  1. * -- Return the Content of the node.
  2. (AttrName) -- Return the value of the given attribute.
  3. $ -- Update the caller's internal reference to be the node (arrived at by following the series of commands). Returns an empty string.

Returns true for success, false for failure.

(C++) ChilkatPath Sample Code

(MFC) ChilkatPath Sample Code

(C++) Get XML Attribute Value by Path

(MFC) Get XML Attribute Value by Path

void Clear(void);

Removes all children, attributes, and content from the XML node. Resets the tag name to "unnamed".

bool ContentMatches(const char *pattern, bool caseSensitive);

Return true if the node's content matches a wildcarded pattern.

void Copy(CkXml &node);

Copies the tag, content, and attributes to the calling node.

void CopyRef(CkXml ©FromNode);

Discards the caller's current internal reference and copies the internal reference from copyFromNode. Effectively updates the caller node to point to the same node in the XML document as copyFromNode.

bool DecodeContent(CkByteData &outData);

Decodes a node's Q or B-encoded content string and returns the byte data.

Returns true for success, false for failure.

bool DecodeEntities(const char *str, CkString &outStr);
const char *decodeEntities(const char *str);

Utility method to decode HTML entities. It accepts a string containing (potentially) HTML entities and returns a string with the entities decoded.

Returns true for success, false for failure.

bool DecryptContent(const char *password);

Decrypts the content of an XML node that was previously 128-bit AES encrypted with the EncryptContent method.

Returns true for success, false for failure.

(C++) Encrypting and Decrypting Content

(MFC) Encrypting and Decrypting Content

bool EncryptContent(const char *password);

Encrypts the content of the calling XML node using 128-bit CBC AES encryption. The base64-encoded encrypted content replaces the original content.

Returns true for success, false for failure.

(C++) Encrypting and Decrypting Content

(MFC) Encrypting and Decrypting Content

CkXml *ExtractChildByIndex(int index);

Removes and returns the Nth child of an XML node. The first child is at index 0.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

CkXml *ExtractChildByName(const char *tagPath, const char *attrName, const char *attrValue);

Removes and returns the first child node at the specified tag or tag path. The attrName and attrValue may be empty, in which case the first child matching the tag is removed and returned. If attrName is specified, then the first child having a tag equal to tagPath, and an attribute with attrName is returned. If attrValue is also specified, then only a child having a tag equal to tagPath, and an attribute named attrName, with a value equal to attrValue is returned.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) ExtractChildByName using a Tag Path

(MFC) ExtractChildByName using a Tag Path

CkXml *FindChild(const char *tagPath);

Returns the child with the given tag or at the specified tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Find Direct Child with Specific Tag

(MFC) Find Direct Child with Specific Tag

(C++) Access SOAP Body XML

(MFC) Access SOAP Body XML

bool FindChild2(const char *tagPath);

Updates the Xml object's internal reference to point to a child at the specified tag or tagPath.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Returns true for success, false for failure.

(C++) Find Direct Child with Specific Tag

(MFC) Find Direct Child with Specific Tag

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

CkXml *FindNextRecord(const char *tagPath, const char *contentPattern);

Returns the next record node where the child with a specific tag matches a wildcarded pattern. This method makes it easy to iterate over high-level records.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Demonstrate the XML FindNextRecord Method

(MFC) Demonstrate the XML FindNextRecord Method

CkXml *FindOrAddNewChild(const char *tagPath);

First checks for a child at tagPath, and if found, returns it. Otherwise creates a new child with empty content.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

CkXml *FirstChild(void);

Returns the first child. A program can step through the children by calling FirstChild, and then NextSibling repeatedly.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

bool FirstChild2(void);

Updates the internal reference of the caller to point to its first child.

Returns true for success, false for failure.

More information about XML methods ending in "2"

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

bool GetAttributeName(int index, CkString &outStr);
const char *getAttributeName(int index);

Returns the name of the Nth attribute of an XML node. The first attribute is at index 0.

Returns true for success, false for failure.

(C++) Methods for Getting Attributes

(MFC) Methods for Getting Attributes

bool GetAttributeValue(int index, CkString &outStr);
const char *getAttributeValue(int index);

Returns the value of the Nth attribute of an XML node. The first attribute is at index 0.

Returns true for success, false for failure.

(C++) Methods for Getting Attributes

(MFC) Methods for Getting Attributes

int GetAttributeValueInt(int index);

Returns an attribute as an integer. Returns 0 if the attribute does not exist.

bool GetAttrValue(const char *name, CkString &outStr);
const char *getAttrValue(const char *name);

Find and return the value of an attribute having a specified name.

Returns true for success, false for failure.

(C++) Methods for Getting Attributes

(MFC) Methods for Getting Attributes

int GetAttrValueInt(const char *name);

Returns an attribute as an integer. Returns 0 if the attribute does not exist.

(C++) Methods for Getting Attributes

(MFC) Methods for Getting Attributes

bool GetBinaryContent(bool unzipFlag, bool decryptFlag, const char *password, CkByteData &outData);

Returns binary content of an XML node as a byte array. The content may have been Zip compressed, AES encrypted, or both. Unzip compression and AES decryption flags should be set appropriately.

Returns true for success, false for failure.

CkXml *GetChild(int index);

Returns the Nth child of an XML node

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Iterate over Direct Child Nodes by Index

(MFC) Iterate over Direct Child Nodes by Index

bool GetChild2(int index);

Updates the calling object's internal reference to the Nth child node.

Returns true for success, false for failure.

More information about XML methods ending in "2"

(C++) Iterate over Direct Child Nodes by Index

(MFC) Iterate over Direct Child Nodes by Index

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

bool GetChildBoolValue(const char *tagPath);

Returns false if the node's content is "0", otherwise returns true if the node contains a non-zero integer. The tagPath can be a tag or a tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red".

(C++) Demonstrate the XML "I" Property

(MFC) Demonstrate the XML "I" Property

bool GetChildContent(const char *tagPath, CkString &outStr);
const char *getChildContent(const char *tagPath);

Returns the content of a child having a specified tag. The tagPath can be a tag or a tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red".

Returns true for success, false for failure.

(C++) Demonstrate the XML "I" Property

(MFC) Demonstrate the XML "I" Property

bool GetChildContentByIndex(int index, CkString &outStr);
const char *getChildContentByIndex(int index);

Returns the content of the Nth child node.

Returns true for success, false for failure.

(C++) Iterate over Direct Child Nodes by Index

(MFC) Iterate over Direct Child Nodes by Index

(C++) SQS List Queues

(MFC) SQS List Queues

CkXml *GetChildExact(const char *tag, const char *content);

Returns the child having the exact tag and content.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

int GetChildIntValue(const char *tagPath);

Returns the child integer content for a given tag. The tagPath can be a tag or a tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red".

(C++) Demonstrate the XML "I" Property

(MFC) Demonstrate the XML "I" Property

bool GetChildTag(int index, CkString &outStr);
const char *getChildTag(int index);

Returns the tag name of the Nth child node.

Returns true for success, false for failure.

bool GetChildTagByIndex(int index, CkString &outStr);
const char *getChildTagByIndex(int index);

Returns the tag name of the Nth child node.

Returns true for success, false for failure.

(C++) Iterate over Direct Child Nodes by Index

(MFC) Iterate over Direct Child Nodes by Index

CkXml *GetChildWithAttr(const char *tagPath, const char *attrName, const char *attrValue);

Finds and returns the XML child node having both a given tag and an attribute with a given name and value.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) XML GetChildWithAttr

(MFC) XML GetChildWithAttr

CkXml *GetChildWithContent(const char *content);

Returns the first child found having the exact content specified.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

CkXml *GetChildWithTag(const char *tagPath);

Returns the child at the specified tag or tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

CkXml *GetNthChildWithTag(const char *tag, int n);

Returns the Nth child having a tag that matches exactly with the tagName. Use the NumChildrenHavingTag method to determine how many children have a particular tag.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Iterate over Direct Children with a Specific Tag

(MFC) Iterate over Direct Children with a Specific Tag

bool GetNthChildWithTag2(const char *tag, int n);

Updates the calling object's internal reference to the Nth child node having a specific tag.

Returns true for success, false for failure.

(C++) Iterate over Direct Children with a Specific Tag

(MFC) Iterate over Direct Children with a Specific Tag

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

CkXml *GetParent(void);

Returns the parent of this XML node, or NULL if the node is the root of the tree.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

bool GetParent2(void);

Updates the internal reference of the caller to its parent.

Returns true for success, false for failure.

More information about XML methods ending in "2"

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

CkXml *GetRoot(void);

Returns the root node of the XML document

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

void GetRoot2(void);

Updates the internal reference of the caller to the document root.

More information about XML methods ending in "2"

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

CkXml *GetSelf(void);

Returns a new XML object instance that references the same XML node.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

bool GetXml(CkString &outStr);
const char *getXml(void);

Generate the XML text document for the XML tree rooted at this node. If called from the root node of the XML document, then the XML declarator ("<?xml version="1.0" encoding="utf-8" ?>") is included at the beginning of the XML. Otherwise, it is not included.

Returns true for success, false for failure.

bool GetXmlSb(CkStringBuilder &sb);

Introduced in version 9.5.0.62

Emits the XML to a StringBuilder object. (Appends to the existing contents of sb.)

Returns true for success, false for failure.

bool HasAttribute(const char *name);

Returns true if the node contains an attribute with the specified name.

bool HasAttrWithValue(const char *name, const char *value);

Returns true if the node contains attribute with the name and value.

bool HasChildWithContent(const char *content);

Returns true if the node has a direct child node containing the exact content string specified.

bool HasChildWithTag(const char *tagPath);

Returns true if the node has a child with the given tag (or tag path). Otherwise returns false.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

(C++) UpdateChildContent using a Tag Path

(MFC) UpdateChildContent using a Tag Path

bool HasChildWithTagAndContent(const char *tagPath, const char *content);

Returns true if the node contains child with the given tag (or tag path) and content specified.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

void InsertChildTreeAfter(int index, CkXml &tree);

Adds an entire subtree as a child. If the child was a subtree within another Xml document then the subtree is effectively transferred from one XML document to another. The child tree is inserted in a position after the Nth child (of the calling node).

void InsertChildTreeBefore(int index, CkXml &tree);

Adds an entire subtree as a child. If the child was a subtree within another Xml document then the subtree is effectively transferred from one XML document to another. The child tree is inserted in a position before the Nth child (of the calling node).

CkXml *LastChild(void);

Returns the last Xml child node. A node's children can be enumerated by calling LastChild and then repeatedly calling PreviousSibling, until a NULL is returned.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

bool LastChild2(void);

Updates the internal reference of the caller to its last child.

Returns true for success, false for failure.

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

bool LoadSb(CkStringBuilder &sb, bool autoTrim);

Introduced in version 9.5.0.62

Loads XML from the contents of a StringBuilder object.

Returns true for success, false for failure.

bool LoadXml(const char *xmlData);

Loads an XML document from a memory buffer and returns true if successful. The contents of the calling node are replaced with the root node of the XML document loaded.

Returns true for success, false for failure.

bool LoadXml2(const char *xmlData, bool autoTrim);

Same as LoadXml, but an additional argument controls whether or not leading/trailing whitespace is auto-trimmed from each node's content.

Returns true for success, false for failure.

bool LoadXmlFile(const char *fileName);

Loads an XML document from a file and returns true if successful. The contents of the calling node are replaced with the root node of the XML document loaded.

Returns true for success, false for failure.

bool LoadXmlFile2(const char *fileName, bool autoTrim);

Same as LoadXmlFile, but an additional argument controls whether or not leading/trailing whitespace is auto-trimmed from each node's content.

Returns true for success, false for failure.

CkXml *NewChild(const char *tagPath, const char *content);

Creates a new child having tag and content. The new child is created even if a child with a tag equal to tagPath already exists. (Use FindOrAddNewChild to prevent creating children having the same tags.)

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red". See the example below for details.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Creating a New Child Node

(MFC) Creating a New Child Node

(C++) NewChild using a Tag Path

(MFC) NewChild using a Tag Path

void NewChild2(const char *tagPath, const char *content);

Creates a new child node, but does not return the node that is created. The tagPath can be a tag or a tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red". See the example below for details.

(C++) Creating a New Child Node

(MFC) Creating a New Child Node

(C++) XML NewChild2 using a Tag Path

(MFC) XML NewChild2 using a Tag Path

CkXml *NewChildAfter(int index, const char *tag, const char *content);

Inserts a new child in a position after the Nth child node.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

CkXml *NewChildBefore(int index, const char *tag, const char *content);

Inserts a new child in a position before the Nth child node.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

void NewChildInt2(const char *tagPath, int value);

Inserts a new child having an integer for content. The tagPath can be a tag or a tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red". See the example below for details.

(C++) Demonstrate the XML NewChildInt2 Method

(MFC) Demonstrate the XML NewChildInt2 Method

CkXml *NextSibling(void);

Returns the nodes next sibling, or NULL if there are no more.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

bool NextSibling2(void);

Updates the internal reference of the caller to its next sibling.

Returns true for success, false for failure.

More information about XML methods ending in "2"

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

int NumChildrenAt(const char *tagPath);

Introduced in version 9.5.0.64

Returns the number of children for the node indicated by tagPath. Returns -1 if the node at tagPath does not exist.

(C++) Demonstrate the XML "I" Property

(MFC) Demonstrate the XML "I" Property

(C++) Demonstrate the XML I, J, and K Properties

(MFC) Demonstrate the XML I, J, and K Properties

(C++) Get XML Attribute Value by Path

(MFC) Get XML Attribute Value by Path

int NumChildrenHavingTag(const char *tag);

Returns the number of children having a specific tag name.

(C++) Iterate over Direct Children with a Specific Tag

(MFC) Iterate over Direct Children with a Specific Tag

CkXml *PreviousSibling(void);

Returns the Xml object that is the node's previous sibling, or NULL if there are no more.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

bool PreviousSibling2(void);

Updates the internal reference of the caller to its previous sibling.

Returns true for success, false for failure.

More information about XML methods ending in "2"

(C++) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(MFC) Traverse Direct Children via FirstChild / NextSibling, or LastChild / PreviousSibling

(C++) Benefit of XML Methods Having Names Ending in "2"

(MFC) Benefit of XML Methods Having Names Ending in "2"

bool QEncodeContent(const char *charset, CkByteData &inData);

Sets the node's content with 8bit data that is in a specified multibyte character encoding such as utf-8, shift-jis, big5, etc. The data is first Q-encoded and the content is set to be the Q-encoded string. For example, if called with "gb2312"for the charset, you would get a string that looks something like this: "=?gb2312?Q?=C5=B5=BB=F9?=". Character that are not 7bit are represented as "=XX" where XX is the hexidecimal value of the byte. Use the DecodeContent method to retrieve the byte data from a Q encoded string.

Returns true for success, false for failure.

bool RemoveAllAttributes(void);

Removes all attributes from an XML node. Should always return True.

Returns true for success, false for failure.

void RemoveAllChildren(void);

Removes all children from the calling node.

bool RemoveAttribute(const char *name);

Removes an attribute by name from and XML node.

Returns true for success, false for failure.

void RemoveChild(const char *tagPath);

Removes all children with a given tag or tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

(C++) Removing / Deleting Child Nodes from XML

(MFC) Removing / Deleting Child Nodes from XML

(C++) RemoveChild using a Tag Path

(MFC) RemoveChild using a Tag Path

void RemoveChildByIndex(int index);

Removes the Nth child from the calling node.

(C++) Removing / Deleting Child Nodes from XML

(MFC) Removing / Deleting Child Nodes from XML

void RemoveChildWithContent(const char *content);

Removes all children having the exact content specified.

(C++) Removing / Deleting Child Nodes from XML

(MFC) Removing / Deleting Child Nodes from XML

void RemoveFromTree(void);

Removes the calling object and its sub-tree from the XML document making it the root of its own tree.

(C++) Removing / Deleting Child Nodes from XML

(MFC) Removing / Deleting Child Nodes from XML

bool SaveBinaryContent(const char *filename, bool unzipFlag, bool decryptFlag, const char *password);

Saves a node's binary content to a file.

Returns true for success, false for failure.

bool SaveLastError(const char *path);

Saves the last-error information (the contents of LastErrorXml) to an XML formatted file.

Returns true for success, false for failure.

bool SaveXml(const char *fileName);

Generates XML representing the tree or subtree rooted at this node and writes it to a file.

Returns true for success, false for failure.

CkXml *SearchAllForContent(CkXml *afterPtr, const char *contentPattern);

Returns the first node having content matching the contentPattern. The contentPattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to NULL. (For the ActiveX implementation, the afterPtr should never be NULL. A reference to the caller's node should be passed instead.)

To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchAllForContent, until the method returns NULL.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) XML Tree Traversal Order for Search* Methods

(MFC) XML Tree Traversal Order for Search* Methods

bool SearchAllForContent2(CkXml *afterPtr, const char *contentPattern);

Same as SearchAllForContent except the internal reference of the caller is updated to point to the search result (instead of returning a new object).

Returns true for success, false for failure.

CkXml *SearchForAttribute(CkXml *afterPtr, const char *tag, const char *attr, const char *valuePattern);

Returns the first node having a tag equal to tag, an attribute named attr, whose value matches valuePattern. The valuePattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to NULL. (For the ActiveX implementation, the afterPtr should never be NULL. A reference to the caller's node should be passed instead.)

To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForAttribute, until the method returns NULL.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) XML SearchForAttribute Method

(MFC) XML SearchForAttribute Method

(C++) XML Tree Traversal Order for Search* Methods

(MFC) XML Tree Traversal Order for Search* Methods

bool SearchForAttribute2(CkXml *afterPtr, const char *tag, const char *attr, const char *valuePattern);

Same as SearchForAttribute except the internal reference of the caller is updated to point to the search result (instead of returning a new object).

Returns true for success, false for failure.

CkXml *SearchForContent(CkXml *afterPtr, const char *tag, const char *contentPattern);

Returns the first node having a tag equal to tag, whose content matches contentPattern. The contentPattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to NULL. (For the ActiveX implementation, the afterPtr should never be NULL. A reference to the caller's node should be passed instead.)

To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForContent, until the method returns NULL.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) XML Tree Traversal Order for Search* Methods

(MFC) XML Tree Traversal Order for Search* Methods

bool SearchForContent2(CkXml *afterPtr, const char *tag, const char *contentPattern);

Same as SearchForContent except the internal reference of the caller is updated to point to the search result (instead of returning a new object).

Returns true for success, false for failure.

(C++) XML Tree Traversal Order for Search* Methods

(MFC) XML Tree Traversal Order for Search* Methods

CkXml *SearchForTag(CkXml *afterPtr, const char *tag);

Returns the first node having a tag equal to tag. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to NULL. (For the ActiveX implementation, the afterPtr should never be NULL. A reference to the caller's node should be passed instead.)

To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForTag, until the method returns NULL.

Note: The application is responsible for deleting (via the C++ delete operator) the object returned by this method.

Returns NULL on failure

(C++) XML SearchForTag Method

(MFC) XML SearchForTag Method

(C++) XML Tree Traversal Order for Search* Methods

(MFC) XML Tree Traversal Order for Search* Methods

bool SearchForTag2(CkXml *afterPtr, const char *tag);

Same as SearchForTag except the internal reference of the caller is updated to point to the search result (instead of returning a new object).

Returns true for success, false for failure.

bool SetBinaryContent(CkByteData &inData, bool zipFlag, bool encryptFlag, const char *password);

Sets the node's content to a block of binary data with optional Zip compression and/or AES encryption. The binary data is automatically converted to base64 format whenever XML text is generated. If the zipFlag is True, the data is first compressed. If the encryptFlag is True, the data is AES encrypted using the Rijndael 128-bit symmetric-encryption algorithm.

Returns true for success, false for failure.

bool SetBinaryContent2(const void *pByteData, unsigned long szByteData, bool zipFlag, bool encryptFlag, const char *password);

The same as SetBinaryContent but the data is provided via a pointer and byte count.

bool SetBinaryContentFromFile(const char *filename, bool zipFlag, bool encryptFlag, const char *password);

Sets the node's content with binary (or text) data from a file. The file contents can be Zip compressed and/or encrypted, and the result is base-64 encoded.

Returns true for success, false for failure.

void SortByAttribute(const char *attrName, bool ascending);

Sorts the direct child nodes by the value of a specified attribute.

void SortByAttributeInt(const char *attrName, bool ascending);

Sorts the direct child nodes by the value of a specified attribute interpreted as an integer (not lexicographically as strings).

void SortByContent(bool ascending);

Sorts the direct child nodes by content.

(C++) XML Sort by Content

(MFC) XML Sort by Content

void SortByTag(bool ascending);

Sorts the direct child nodes by tag.

(C++) XML Sort by Tag

(MFC) XML Sort by Tag

void SortRecordsByAttribute(const char *sortTag, const char *attrName, bool ascending);

Sorts the direct child nodes by the content of an attribute in the grandchild nodes.

void SortRecordsByContent(const char *sortTag, bool ascending);

Sorts the direct child nodes by the content of the grandchild nodes.

(C++) XML Sort Records by Content

(MFC) XML Sort Records by Content

void SortRecordsByContentInt(const char *sortTag, bool ascending);

Sorts the direct child nodes by the content of the grandchild nodes. For sorting purposes, the content is interpreted as an integer (not lexicographically as for strings).

bool SwapNode(CkXml &node);

Swaps another node's tag, content, and attributes with this one.

Returns true for success, false for failure.

bool SwapTree(CkXml &tree);

Swaps another node's tag, content, attributes, and children with this one.

Returns true for success, false for failure.

bool TagContent(const char *tagName, CkString &outStr);
const char *tagContent(const char *tagName);

Returns the content of the 1st node found in the sub-tree rooted at the caller that has a given tag. (Note: The search for the node having tag ARG is not limited to the direct children of the caller.)

Returns true for success, false for failure.

bool TagEquals(const char *tag);

Returns true if the node's tag equals the specified string.

bool UnzipContent(void);

Unzip the content of the XML node replacing it's content with the decompressed data.

Returns true for success, false for failure.

(C++) Compress XML Content

(MFC) Compress XML Content

bool UnzipTree(void);

Unzips and recreates the XML node and the entire subtree, restoring it to the state before it was zip compressed.

Returns true for success, false for failure.

(C++) Compress XML Tree

(MFC) Compress XML Tree

bool UpdateAt(const char *tagPath, bool autoCreate, const char *value);

Introduced in version 9.5.0.64

Updates the content for the node indicated by tagPath. If autoCreate is true, then nodes along tagPath are auto-created as needed.

(C++) Demonstrate the XML UpdateAt Method

(MFC) Demonstrate the XML UpdateAt Method

bool UpdateAttrAt(const char *tagPath, bool autoCreate, const char *attrName, const char *attrValue);

Introduced in version 9.5.0.64

Updates or adds the attribute value for the node indicated by tagPath. If autoCreate is true, then nodes along tagPath are auto-created as needed.

(C++) Demonstrate the XML UpdateAttrAt Method

(MFC) Demonstrate the XML UpdateAttrAt Method

(C++) Xml.UpdateAttrAt Example #2

(MFC) Xml.UpdateAttrAt Example #2

bool UpdateAttribute(const char *attrName, const char *attrValue);

Adds an attribute to the node if it doesn't already exist. Otherwise it updates the existing attribute with the new value.

Returns true for success, false for failure.

(C++) Update an XML Attribute

(MFC) Update an XML Attribute

bool UpdateAttributeInt(const char *attrName, int value);

Updates an attribute value. (Call UpdateAttribute if the attribute value is a string.)

Returns true for success, false for failure.

void UpdateChildContent(const char *tagPath, const char *value);

Replaces the content of a child node. The tagPath can be a tag or tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

(C++) UpdateChildContent using a Tag Path

(MFC) UpdateChildContent using a Tag Path

(C++) Xml.ChildContent Example #2

(MFC) Xml.ChildContent Example #2

void UpdateChildContentInt(const char *tagPath, int value);

Replaces the content of a child node where the content is an integer. The tagPath can be a tag or tag path.

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".

bool ZipContent(void);

Applies Zip compression to the content of an XML node and replaces the content with base64-encoded compressed data.

Returns true for success, false for failure.

(C++) Compress XML Content

(MFC) Compress XML Content

bool ZipTree(void);

Zip compresses the content and entire subtree rooted at the calling XML node and replaces the current content with base64-encoded Zip compressed data. The node and subtree can be restored by calling UnzipTree. Note that the node name and attributes are unaffected.

Returns true for success, false for failure.

(C++) Compress XML Tree

(MFC) Compress XML Tree