Xml C Library Reference

Xml

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

Create/Dispose

HCkXml CkXml_Create(void);

Creates an instance of the CkXml object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.

void CkXml_Dispose(HCkXml handle);

Objects created by calling CkXml_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.

C "Properties"

BOOL CkXml_getCdata(HCkXml cHandle);
void CkXml_putCdata(HCkXml cHandle, BOOL newVal);

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

void CkXml_getContent(HCkXml cHandle, HCkString retval);
void CkXml_putContent(HCkXml cHandle, const char *newVal);

This is the content of the XML node. It is the text between the open and close tags, such as:This is the content

Content vs. Children: A common misconception explained.

int CkXml_getContentInt(HCkXml cHandle);
void CkXml_putContentInt(HCkXml cHandle, int newVal);

Set/get the content as an integer.

void CkXml_getDocType(HCkXml cHandle, HCkString retval);
void CkXml_putDocType(HCkXml cHandle, const char *newVal);

To be documented soon...

void CkXml_getEncoding(HCkXml cHandle, HCkString retval);
void CkXml_putEncoding(HCkXml cHandle, const char *newVal);

This is the encoding attribute in the XML declaration, such as "utf-8" or "iso-8859-1". If not present, this property returns an empty string. 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.

void CkXml_getLastErrorHtml(HCkXml cHandle, HCkString retval);

To be documented soon.Error information in HTML format for the last method called.

void CkXml_getLastErrorText(HCkXml cHandle, HCkString retval);

To be documented soon.Error information in plain-text format for the last method called.

void CkXml_getLastErrorXml(HCkXml cHandle, HCkString retval);

To be documented soon.Error information in XML format for the last method called.

long CkXml_getNumAttributes(HCkXml cHandle);

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

long CkXml_getNumChildren(HCkXml cHandle);

The number of child nodes contained under this XML node.

BOOL CkXml_getSortCaseInsensitive(HCkXml cHandle);
void CkXml_putSortCaseInsensitive(HCkXml cHandle, BOOL newVal);

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

BOOL CkXml_getStandalone(HCkXml cHandle);
void CkXml_putStandalone(HCkXml cHandle, 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 CkXml_getTag(HCkXml cHandle, HCkString retval);
void CkXml_putTag(HCkXml cHandle, const char *newVal);

The XML node's tag.

long CkXml_getTreeId(HCkXml cHandle);

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 CkXml_getUtf8(HCkXml cHandle);
void CkXml_putUtf8(HCkXml cHandle, BOOL newVal);

When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.

BOOL CkXml_getVersion(HCkXml cHandle);

The version of the XML component, such as "2.0.0".

C "Methods"

void CkXml_AccumulateTagContent(HCkXml cHandle, const char *tag, const char *skipTags, HCkString str);

Accumulates the content of all nodes having a specific tag into a single result string. SkipTags specifies a set of tags whose are 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.

BOOL CkXml_AddAttribute(HCkXml cHandle, 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.

BOOL CkXml_AddAttributeInt(HCkXml cHandle, const char *name, int value);

Adds an integer attribute to a node.

BOOL CkXml_AddChildTree(HCkXml cHandle, HCkXml 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.

void CkXml_AddOrUpdateAttribute(HCkXml cHandle, 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.

void CkXml_AddOrUpdateAttributeI(HCkXml cHandle, const char *name, long value);

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

void CkXml_AddStyleSheet(HCkXml cHandle, 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 CkXml_AddToAttribute(HCkXml cHandle, const char *name, long 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.

void CkXml_AddToChildContent(HCkXml cHandle, const char *tag, long amount);

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

void CkXml_AddToContent(HCkXml cHandle, long amount);

Adds an integer amount to the node's content.

BOOL CkXml_AppendToContent(HCkXml cHandle, const char *str);

Appends text to the content of an XML node

BOOL CkXml_BEncodeContent(HCkXml cHandle, const char *charset, HCkByteData db);

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.

BOOL CkXml_ChildContentMatches(HCkXml cHandle, const char *tag, const char *pattern, BOOL caseSensitive);

Return true if a child having a specific tag contains content that matches a wildcarded pattern.

BOOL CkXml_ChilkatPath(HCkXml cHandle, const char *cmd, HCkString outStr);

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.
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.

BOOL CkXml_Clear(HCkXml cHandle);

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

BOOL CkXml_ContentMatches(HCkXml cHandle, const char *pattern, BOOL caseSensitive);

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

BOOL CkXml_DecodeContent(HCkXml cHandle, HCkByteData db);

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

BOOL CkXml_DecodeEntities(HCkXml cHandle, const char *str, HCkString outStr);

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

BOOL CkXml_DecryptContent(HCkXml cHandle, const char *password);

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

BOOL CkXml_EncryptContent(HCkXml cHandle, const char *password);

AES encrypts the content of the calling XML node using 128-bit Rijndael encryption.

HCkXml CkXml_ExtractChildByIndex(HCkXml cHandle, long index);

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

HCkXml CkXml_ExtractChildByName(HCkXml cHandle, const char *tag, const char *attrName, const char *attrValue);

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

HCkXml CkXml_FindChild(HCkXml cHandle, const char *tag);

Returns the child having a specified tag.

BOOL CkXml_FindChild2(HCkXml cHandle, const char *tag);

Updates the Xml object's internal reference to point to a child with a specified tag.

HCkXml CkXml_FindNextRecord(HCkXml cHandle, const char *tag, 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.

HCkXml CkXml_FindOrAddNewChild(HCkXml cHandle, const char *tag);

First searches for a child having a tag equal to tagName, and if found, returns it. Otherwise creates a new child, sets the tag equal to tagName, and initializes the Content to empty.

HCkXml CkXml_FirstChild(HCkXml cHandle);

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

BOOL CkXml_FirstChild2(HCkXml cHandle);

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

More information about XML methods ending in "2"

BOOL CkXml_GetAttrValue(HCkXml cHandle, const char *name, HCkString str);

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

int CkXml_GetAttrValueInt(HCkXml cHandle, const char *name);

Returns an attribute as an integer.

BOOL CkXml_GetAttributeName(HCkXml cHandle, long index, HCkString str);

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

BOOL CkXml_GetAttributeValue(HCkXml cHandle, long index, HCkString str);

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

int CkXml_GetAttributeValueInt(HCkXml cHandle, int index);

Returns an attribute as an integer.

BOOL CkXml_GetBinaryContent(HCkXml cHandle, HCkByteData data, BOOL unzipFlag, BOOL decryptFlag, const char *password);

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.

HCkXml CkXml_GetChild(HCkXml cHandle, long index);

Returns the Nth child of an XML node

BOOL CkXml_GetChild2(HCkXml cHandle, long 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"

BOOL CkXml_GetChildBoolValue(HCkXml cHandle, const char *tag);

Returns false if the node's content is "0", otherwise returns true if the node contains a non-zero integer.

BOOL CkXml_GetChildContent(HCkXml cHandle, const char *tag, HCkString str);

Returns the content of a child having a specified tag.

BOOL CkXml_GetChildContentByIndex(HCkXml cHandle, long index, HCkString str);

Returns the content of the Nth child node.

HCkXml CkXml_GetChildExact(HCkXml cHandle, const char *tag, const char *content);

Returns the child having the exact tag and content.

int CkXml_GetChildIntValue(HCkXml cHandle, const char *tag);

Returns the child integer content for a given tag.

BOOL CkXml_GetChildTag(HCkXml cHandle, long index, HCkString str);

Returns the tag name of the Nth child node.

BOOL CkXml_GetChildTagByIndex(HCkXml cHandle, int index, HCkString outStr);

Returns the tag name of the Nth child node.

HCkXml CkXml_GetChildWithContent(HCkXml cHandle, const char *content);

Returns the first child found having the exact content specified.

HCkXml CkXml_GetChildWithTag(HCkXml cHandle, const char *tag);

Returns the Xml child object having a tag matching tagName.

HCkXml CkXml_GetNthChildWithTag(HCkXml cHandle, const char *tag, long 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.

BOOL CkXml_GetNthChildWithTag2(HCkXml cHandle, const char *tag, long n);

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

Returns TRUE for success, FALSE for failure.

HCkXml CkXml_GetParent(HCkXml cHandle);

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

BOOL CkXml_GetParent2(HCkXml cHandle);

Updates the internal reference of the caller to its parent.

More information about XML methods ending in "2"

HCkXml CkXml_GetRoot(HCkXml cHandle);

Returns the root node of the XML document

void CkXml_GetRoot2(HCkXml cHandle);

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

More information about XML methods ending in "2"

HCkXml CkXml_GetSelf(HCkXml cHandle);

To be documented soon...

BOOL CkXml_GetXml(HCkXml cHandle, HCkString str);

Generate the XML text document for the XML tree rooted at this node.

BOOL CkXml_HasAttrWithValue(HCkXml cHandle, const char *name, const char *value);

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

BOOL CkXml_HasAttribute(HCkXml cHandle, const char *name);

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

BOOL CkXml_HasChildWithContent(HCkXml cHandle, const char *content);

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

BOOL CkXml_HasChildWithTag(HCkXml cHandle, const char *tag);

Returns true (1 for ActiveX) if the node has a child with a given tag.

BOOL CkXml_HasChildWithTagAndContent(HCkXml cHandle, const char *tag, const char *content);

Returns true if the node contains a child having the exact tag and content specified.

HCkXml CkXml_HttpGet(HCkXml cHandle, const char *url);

Gets an XML document from a URL. This can be tested with the following URL: http://www.chilkatsoft.com/test.xml

HCkXml CkXml_HttpPost(HCkXml cHandle, const char *url);

Provides client-side protocol support for communication with HTTP servers. A client can use this method to send an arbitrary HTTP request, receive the response, and have Chilkat XML.NET parse that response.The request body is sent directly from the Chilkat XML object and the response is parsed directly into the returned Chilkat XML object. When combined with the support for Extensible Stylesheet Language (XSL), this provides an easy way to send structured queries to HTTP servers and efficiently display the results with a variety of presentations.

BOOL CkXml_InsertChildTreeAfter(HCkXml cHandle, int index, HCkXml 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).

BOOL CkXml_InsertChildTreeBefore(HCkXml cHandle, int index, HCkXml 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).

HCkXml CkXml_LastChild(HCkXml cHandle);

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.

BOOL CkXml_LastChild2(HCkXml cHandle);

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

BOOL CkXml_LoadXml(HCkXml cHandle, 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.

BOOL CkXml_LoadXml2(HCkXml cHandle, 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 CkXml_LoadXmlFile(HCkXml cHandle, 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.

BOOL CkXml_LoadXmlFile2(HCkXml cHandle, 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.

HCkXml CkXml_NewChild(HCkXml cHandle, const char *tag, 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 tagName already exists. (Use FindOrAddNewChild to prevent creating children having the same tags.)

void CkXml_NewChild2(HCkXml cHandle, const char *tag, const char *content);

Creates a new child but does not return the node that is created.

HCkXml CkXml_NewChildAfter(HCkXml cHandle, int index, const char *tag, const char *content);

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

HCkXml CkXml_NewChildBefore(HCkXml cHandle, int index, const char *tag, const char *content);

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

void CkXml_NewChildInt2(HCkXml cHandle, const char *tag, int value);

Inserts a new child having an integer for content.

HCkXml CkXml_NextSibling(HCkXml cHandle);

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

BOOL CkXml_NextSibling2(HCkXml cHandle);

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

More information about XML methods ending in "2"

long CkXml_NumChildrenHavingTag(HCkXml cHandle, const char *tag);

Returns the number of children having a specific tag name.

HCkXml CkXml_PreviousSibling(HCkXml cHandle);

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

BOOL CkXml_PreviousSibling2(HCkXml cHandle);

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

More information about XML methods ending in "2"

BOOL CkXml_QEncodeContent(HCkXml cHandle, const char *charset, HCkByteData db);

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.

BOOL CkXml_RemoveAllAttributes(HCkXml cHandle);

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

void CkXml_RemoveAllChildren(HCkXml cHandle);

Removes all children from the calling node.

BOOL CkXml_RemoveAttribute(HCkXml cHandle, const char *name);

Removes an attribute by name from and XML node.

void CkXml_RemoveChild(HCkXml cHandle, const char *tag);

Removes a child with a given tag.

void CkXml_RemoveChildByIndex(HCkXml cHandle, long index);

Removes the Nth child from the calling node.

void CkXml_RemoveChildWithContent(HCkXml cHandle, const char *content);

Removes all children having the exact content specified.

void CkXml_RemoveFromTree(HCkXml cHandle);

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

BOOL CkXml_SaveBinaryContent(HCkXml cHandle, const char *filename, BOOL unzipFlag, BOOL decryptFlag, const char *password);

Saves a node's binary content to a file.

BOOL CkXml_SaveLastError(HCkXml cHandle, const char *filename);

Saves the last error information to an XML formatted file.

BOOL CkXml_SaveXml(HCkXml cHandle, const char *fileName);

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

HCkXml CkXml_SearchAllForContent(HCkXml cHandle, HCkXml after, const char *contentPattern);

Returns the first node whose content matches the contentPattern, which is a case-sensitive string that can use any number of '*'s to represent 0 or more occurances of any character. The search is breadth-first over the tree, and the previous node returned can be passed to the next call as afterNode to continue the search after that node.

BOOL CkXml_SearchAllForContent2(HCkXml cHandle, HCkXml after, 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).

HCkXml CkXml_SearchForAttribute(HCkXml cHandle, HCkXml after, const char *tag, const char *attr, const char *valuePattern);

Returns the first node having a tag equal to tagName, and an attribute named attrName whose value matches valuePattern, which is a case-sensitive string that can use any number of '*'s to represent 0 or more occurances of any character. The search is breadth-first over the tree, and the previous node returned can be passed to the next call as afterNode to continue the search after that node.

BOOL CkXml_SearchForAttribute2(HCkXml cHandle, HCkXml after, 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).

HCkXml CkXml_SearchForContent(HCkXml cHandle, HCkXml after, const char *tag, const char *contentPattern);

Returns the first node having a tag equal to tagName whose content matches contentPattern, which is a case-sensitive string that can use any number of '*'s to represent 0 or more occurances of any character. The search is breadth-first over the tree, and the previous node returned can be passed to the next call as afterNode to continue the search after that node.

BOOL CkXml_SearchForContent2(HCkXml cHandle, HCkXml after, 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).

HCkXml CkXml_SearchForTag(HCkXml cHandle, HCkXml after, const char *tag);

Returns the first node having a tag equal to tagName. The search is breadth-first over the tree, and the previous node returned can be passed to the next call as afterNode to continue the search after that node.

BOOL CkXml_SearchForTag2(HCkXml cHandle, HCkXml after, 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).

BOOL CkXml_SetBinaryContent(HCkXml cHandle, const unsigned char *data, unsigned long dataLen, 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.

BOOL CkXml_SetBinaryContent(HCkXml cHandle, HCkByteData data, 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.

BOOL CkXml_SetBinaryContentFromFile(HCkXml cHandle, 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.

void CkXml_SortByAttribute(HCkXml cHandle, const char *attrName, long ascending);

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

void CkXml_SortByAttributeInt(HCkXml cHandle, const char *attrName, BOOL ascending);

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

void CkXml_SortByContent(HCkXml cHandle, long ascending);

Sorts the child nodes by content.

void CkXml_SortByTag(HCkXml cHandle, long ascending);

Sorts the child nodes by tag.

void CkXml_SortRecordsByAttribute(HCkXml cHandle, const char *sortTag, const char *attrName, long ascending);

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

void CkXml_SortRecordsByContent(HCkXml cHandle, const char *sortTag, long ascending);

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

void CkXml_SortRecordsByContentInt(HCkXml cHandle, const char *sortTag, BOOL ascending);

To be documented soon...

BOOL CkXml_SwapNode(HCkXml cHandle, HCkXml node);

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

BOOL CkXml_SwapTree(HCkXml cHandle, HCkXml tree);

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

BOOL CkXml_TagContent(HCkXml cHandle, const char *tag, HCkString outStr);

To be documented soon...

BOOL CkXml_TagEquals(HCkXml cHandle, const char *tag);

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

BOOL CkXml_UnzipContent(HCkXml cHandle);

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

BOOL CkXml_UnzipTree(HCkXml cHandle);

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

BOOL CkXml_UpdateAttribute(HCkXml cHandle, 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.

BOOL CkXml_UpdateAttributeInt(HCkXml cHandle, const char *attrName, int value);

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

void CkXml_UpdateChildContent(HCkXml cHandle, const char *tag, const char *value);

Replaces the content of a child node.

void CkXml_UpdateChildContentInt(HCkXml cHandle, const char *tag, int value);

Replaces the content of a child node where the content is an integer.

BOOL CkXml_ZipContent(HCkXml cHandle);

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

BOOL CkXml_ZipTree(HCkXml cHandle);

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.

const char *CkXml_accumulateTagContent(HCkXml cHandle, 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 tags whose are 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.

const char *CkXml_attr(HCkXml cHandle, const char *name);

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

const char *CkXml_attrName(HCkXml cHandle, long index);

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

const char *CkXml_attrValue(HCkXml cHandle, long index);

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

const char *CkXml_childContent(HCkXml cHandle, const char *tag);

Returns the content of a child having a specified tag.

const char *CkXml_chilkatPath(HCkXml cHandle, const char *cmd);

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.
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.

const char *CkXml_content(HCkXml cHandle);

This is the content of the XML node. It is the text between the open and close tags, such as:This is the content

Content vs. Children: A common misconception explained.

const char *CkXml_decodeEntities(HCkXml cHandle, 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.

const char *CkXml_docType(HCkXml cHandle);

To be documented soon...

const char *CkXml_encoding(HCkXml cHandle);

This is the encoding attribute in the XML declaration, such as "utf-8" or "iso-8859-1". If not present, this property returns an empty string. 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.

const char *CkXml_getAttrValue(HCkXml cHandle, const char *name);

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

const char *CkXml_getAttributeName(HCkXml cHandle, long index);

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

const char *CkXml_getAttributeValue(HCkXml cHandle, long index);

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

const char *CkXml_getChildContent(HCkXml cHandle, const char *tag);

Returns the content of a child having a specified tag.

const char *CkXml_getChildContentByIndex(HCkXml cHandle, long index);

Returns the content of the Nth child node.

const char *CkXml_getChildTag(HCkXml cHandle, long index);

Returns the tag name of the Nth child node.

const char *CkXml_getChildTagByIndex(HCkXml cHandle, int index);

Returns the tag name of the Nth child node.

const char *CkXml_getXml(HCkXml cHandle);

Generate the XML text document for the XML tree rooted at this node.

const char *CkXml_lastErrorHtml(HCkXml cHandle);

Error information in HTML format for the last method called.

const char *CkXml_lastErrorText(HCkXml cHandle);

Error information in plain-text format for the last method called.

const char *CkXml_lastErrorXml(HCkXml cHandle);

Error information in XML format for the last method called.

const char *CkXml_tag(HCkXml cHandle);

The XML node's tag.

const char *CkXml_tagContent(HCkXml cHandle, const char *tag);

To be documented soon...

const char *CkXml_version(HCkXml cHandle);

The version of the XML component, such as "2.0.0".

const char *CkXml_xml(HCkXml cHandle);

Generate the XML text document for the XML tree rooted at this node.