---
product: Chilkat
product_version: 11.7.0
language: c
language_label: C
class: Xml
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/c_CkXmlRef.html
---
# Chilkat Xml — C — v11.7.0

> Chilkat 11.7.0 · language=c · class=Xml
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/Xml.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/guide.md`.

## Purpose

**Load, navigate, search, edit, transform, and save in-memory XML trees.**

`Chilkat.Xml` is the primary Chilkat class for in-memory XML tree manipulation. It supports loading and saving XML, navigating between elements, reading and writing text content, managing attributes, working with namespaces, adding and removing subtrees, searching by tag, content, or attribute, sorting child records, scrubbing XML, handling CDATA and XML declarations, storing binary data as Base64, and optionally compressing or encrypting element content.

**Load and save XML**

Load XML from strings, files, byte data, or other Chilkat objects, then save or emit formatted XML when processing is complete.

**Navigate XML trees**

Move through parent, child, sibling, and selected elements while working directly with the XML document structure.

**Edit elements and attributes**

Add, update, remove, or rename elements; set text content; and read, add, modify, or delete attributes.

**Search and select**

Locate elements by tag name, content, path, attribute value, or custom search patterns.

**Namespaces and structure**

Work with namespace-aware XML, declarations, CDATA, child ordering, sorting, and subtree insertion or removal.

**Binary and protected content**

Store binary data as Base64 and optionally compress or encrypt element content when XML carries encoded payloads.

**Important usage distinction:** Some methods return a new `Xml` object reference for the selected element, while methods ending in `2` update the caller's internal reference to point to a different element. This distinction is central when navigating and editing XML trees because it determines whether the current object stays where it is or moves to another element.

**Common pattern:** Load or create the XML document, navigate to the element of interest, read or modify content and attributes, add or remove child elements as needed, then save the updated XML. Use `Chilkat.Xml` for tree-oriented XML manipulation, and use `Chilkat.XmlDSig`, `Chilkat.XmlDSigGen`, or related classes when the task is XML digital signing or signature verification.

For an extended overview, see [Xml Class Overview](https://www.chilkatsoft.com/xml_class_overview.asp).

## Object creation, unlocking and error handling

**Create/Dispose**

```c
HCkXml instance = CkXml_Create();
// ...
CkXml_Dispose(instance);
```

`HCkXml CkXml_Create(void);`

Creates an instance of the HCkXml object and returns a handle ("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. Also, any handle returned by a Chilkat "C" function must also be freed by the application by calling the appropriate Dispose method, such as CkXml_Dispose.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in C.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `void CkXml_getDebugLogFilePath(HCkXml cHandle, HCkString retval); void CkXml_putDebugLogFilePath(HCkXml cHandle, const char *newVal); const char *CkXml_debugLogFilePath(HCkXml cHandle);` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastErrorHtml` | `void CkXml_getLastErrorHtml(HCkXml cHandle, HCkString retval); const char *CkXml_lastErrorHtml(HCkXml cHandle);` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `void CkXml_getLastErrorText(HCkXml cHandle, HCkString retval); const char *CkXml_lastErrorText(HCkXml cHandle);` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `void CkXml_getLastErrorXml(HCkXml cHandle, HCkString retval); const char *CkXml_lastErrorXml(HCkXml cHandle);` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `BOOL CkXml_getLastMethodSuccess(HCkXml cHandle); void CkXml_putLastMethodSuccess(HCkXml cHandle, BOOL newVal);` | read/write | Indicates the success or failure of the most recent method call: `TRUE` means success, `FALSE` means failure. |
| `Utf8` | `BOOL CkXml_getUtf8(HCkXml cHandle); void CkXml_putUtf8(HCkXml cHandle, BOOL newVal);` | read/write | When set to `TRUE`, all `const char *` arguments and return values are interpreted as UTF-8 strings. |
| `VerboseLogging` | `BOOL CkXml_getVerboseLogging(HCkXml cHandle); void CkXml_putVerboseLogging(HCkXml cHandle, BOOL newVal);` | read/write | If set to `TRUE`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `void CkXml_getVersion(HCkXml cHandle, HCkString retval); const char *CkXml_version(HCkXml cHandle);` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Cdata` | property, read/write | `BOOL CkXml_getCdata(HCkXml cHandle); void CkXml_putCdata(HCkXml cHandle, BOOL newVal);` |
| `Content` | property, read/write | `void CkXml_getContent(HCkXml cHandle, HCkString retval); void CkXml_putContent(HCkXml cHandle, const char *newVal); const char *CkXml_content(HCkXml cHandle);` |
| `ContentInt` | property, read/write | `int CkXml_getContentInt(HCkXml cHandle); void CkXml_putContentInt(HCkXml cHandle, int newVal);` |
| `DocType` | property, read/write | `void CkXml_getDocType(HCkXml cHandle, HCkString retval); void CkXml_putDocType(HCkXml cHandle, const char *newVal); const char *CkXml_docType(HCkXml cHandle);` |
| `EmitBom` | property, read/write | `BOOL CkXml_getEmitBom(HCkXml cHandle); void CkXml_putEmitBom(HCkXml cHandle, BOOL newVal);` |
| `EmitCompact` | property, read/write | `BOOL CkXml_getEmitCompact(HCkXml cHandle); void CkXml_putEmitCompact(HCkXml cHandle, BOOL newVal);` |
| `EmitXmlDecl` | property, read/write | `BOOL CkXml_getEmitXmlDecl(HCkXml cHandle); void CkXml_putEmitXmlDecl(HCkXml cHandle, BOOL newVal);` |
| `Encoding` | property, read/write | `void CkXml_getEncoding(HCkXml cHandle, HCkString retval); void CkXml_putEncoding(HCkXml cHandle, const char *newVal); const char *CkXml_encoding(HCkXml cHandle);` |
| `I` | property, read/write | `int CkXml_getI(HCkXml cHandle); void CkXml_putI(HCkXml cHandle, int newVal);` |
| `IsBase64` | property, read-only | `BOOL CkXml_getIsBase64(HCkXml cHandle);` |
| `J` | property, read/write | `int CkXml_getJ(HCkXml cHandle); void CkXml_putJ(HCkXml cHandle, int newVal);` |
| `K` | property, read/write | `int CkXml_getK(HCkXml cHandle); void CkXml_putK(HCkXml cHandle, int newVal);` |
| `NumAttributes` | property, read-only | `int CkXml_getNumAttributes(HCkXml cHandle);` |
| `NumChildren` | property, read-only | `int CkXml_getNumChildren(HCkXml cHandle);` |
| `SortCaseInsensitive` | property, read/write | `BOOL CkXml_getSortCaseInsensitive(HCkXml cHandle); void CkXml_putSortCaseInsensitive(HCkXml cHandle, BOOL newVal);` |
| `Standalone` | property, read/write | `BOOL CkXml_getStandalone(HCkXml cHandle); void CkXml_putStandalone(HCkXml cHandle, BOOL newVal);` |
| `Strict` | property, read/write | `BOOL CkXml_getStrict(HCkXml cHandle); void CkXml_putStrict(HCkXml cHandle, BOOL newVal);` |
| `Tag` | property, read/write | `void CkXml_getTag(HCkXml cHandle, HCkString retval); void CkXml_putTag(HCkXml cHandle, const char *newVal); const char *CkXml_tag(HCkXml cHandle);` |
| `TagNsPrefix` | property, read/write | `void CkXml_getTagNsPrefix(HCkXml cHandle, HCkString retval); void CkXml_putTagNsPrefix(HCkXml cHandle, const char *newVal); const char *CkXml_tagNsPrefix(HCkXml cHandle);` |
| `TagPath` | property, read-only | `void CkXml_getTagPath(HCkXml cHandle, HCkString retval); const char *CkXml_tagPath(HCkXml cHandle);` |
| `TagUnprefixed` | property, read/write | `void CkXml_getTagUnprefixed(HCkXml cHandle, HCkString retval); void CkXml_putTagUnprefixed(HCkXml cHandle, const char *newVal); const char *CkXml_tagUnprefixed(HCkXml cHandle);` |
| `TreeId` | property, read-only | `int CkXml_getTreeId(HCkXml cHandle);` |
| `UncommonOptions` | property, read/write | `void CkXml_getUncommonOptions(HCkXml cHandle, HCkString retval); void CkXml_putUncommonOptions(HCkXml cHandle, const char *newVal); const char *CkXml_uncommonOptions(HCkXml cHandle);` |
| `AccumulateTagContent` | method | `BOOL CkXml_AccumulateTagContent(HCkXml cHandle, const char *tag, const char *skipTags, HCkString outStr); const char *CkXml_accumulateTagContent(HCkXml cHandle, const char *tag, const char *skipTags);` |
| `AddAttribute` | method | `BOOL CkXml_AddAttribute(HCkXml cHandle, const char *name, const char *value);` |
| `AddAttributeInt` | method | `BOOL CkXml_AddAttributeInt(HCkXml cHandle, const char *name, int value);` |
| `AddChildTree` | method | `BOOL CkXml_AddChildTree(HCkXml cHandle, HCkXml tree);` |
| `AddOrUpdateAttribute` | method | `void CkXml_AddOrUpdateAttribute(HCkXml cHandle, const char *name, const char *value);` |
| `AddOrUpdateAttributeI` | method | `void CkXml_AddOrUpdateAttributeI(HCkXml cHandle, const char *name, int value);` |
| `AddStyleSheet` | method | `void CkXml_AddStyleSheet(HCkXml cHandle, const char *styleSheet);` |
| `AddToAttribute` | method | `void CkXml_AddToAttribute(HCkXml cHandle, const char *name, int amount);` |
| `AddToChildContent` | method | `void CkXml_AddToChildContent(HCkXml cHandle, const char *tag, int amount);` |
| `AddToContent` | method | `void CkXml_AddToContent(HCkXml cHandle, int amount);` |
| `AppendToContent` | method | `BOOL CkXml_AppendToContent(HCkXml cHandle, const char *str);` |
| `ChildContentMatches` | method | `BOOL CkXml_ChildContentMatches(HCkXml cHandle, const char *tagPath, const char *pattern, BOOL caseSensitive);` |
| `ChilkatPath` | method | `BOOL CkXml_ChilkatPath(HCkXml cHandle, const char *pathCmd, HCkString outStr); const char *CkXml_chilkatPath(HCkXml cHandle, const char *pathCmd);` |
| `Clear` | method | `void CkXml_Clear(HCkXml cHandle);` |
| `ContentMatches` | method | `BOOL CkXml_ContentMatches(HCkXml cHandle, const char *pattern, BOOL caseSensitive);` |
| `Copy` | method | `void CkXml_Copy(HCkXml cHandle, HCkXml node);` |
| `CopyRef` | method | `void CkXml_CopyRef(HCkXml cHandle, HCkXml copyFromNode);` |
| `DecodeEntities` | method | `BOOL CkXml_DecodeEntities(HCkXml cHandle, const char *str, HCkString outStr); const char *CkXml_decodeEntities(HCkXml cHandle, const char *str);` |
| `DecryptContent` | method | `BOOL CkXml_DecryptContent(HCkXml cHandle, const char *password);` |
| `EncryptContent` | method | `BOOL CkXml_EncryptContent(HCkXml cHandle, const char *password);` |
| `ExtractChildByIndex` | method | `HCkXml CkXml_ExtractChildByIndex(HCkXml cHandle, int index);` |
| `ExtractChildByName` | method | `HCkXml CkXml_ExtractChildByName(HCkXml cHandle, const char *tagPath, const char *attrName, const char *attrValue);` |
| `FindChild` | method | `HCkXml CkXml_FindChild(HCkXml cHandle, const char *tagPath);` |
| `FindChild2` | method | `BOOL CkXml_FindChild2(HCkXml cHandle, const char *tagPath);` |
| `FindNextRecord` | method | `HCkXml CkXml_FindNextRecord(HCkXml cHandle, const char *tagPath, const char *contentPattern);` |
| `FindOrAddNewChild` | method | `HCkXml CkXml_FindOrAddNewChild(HCkXml cHandle, const char *tagPath);` |
| `FirstChild` | method | `HCkXml CkXml_FirstChild(HCkXml cHandle);` |
| `FirstChild2` | method | `BOOL CkXml_FirstChild2(HCkXml cHandle);` |
| `GetAttributeName` | method | `BOOL CkXml_GetAttributeName(HCkXml cHandle, int index, HCkString outStr); const char *CkXml_getAttributeName(HCkXml cHandle, int index);` |
| `GetAttributeValue` | method | `BOOL CkXml_GetAttributeValue(HCkXml cHandle, int index, HCkString outStr); const char *CkXml_getAttributeValue(HCkXml cHandle, int index);` |
| `GetAttributeValueInt` | method | `int CkXml_GetAttributeValueInt(HCkXml cHandle, int index);` |
| `GetAttrValue` | method | `BOOL CkXml_GetAttrValue(HCkXml cHandle, const char *name, HCkString outStr); const char *CkXml_getAttrValue(HCkXml cHandle, const char *name);` |
| `GetAttrValueInt` | method | `int CkXml_GetAttrValueInt(HCkXml cHandle, const char *name);` |
| `GetChild` | method | `HCkXml CkXml_GetChild(HCkXml cHandle, int index);` |
| `GetChild2` | method | `BOOL CkXml_GetChild2(HCkXml cHandle, int index);` |
| `GetChildAttrValue` | method | `BOOL CkXml_GetChildAttrValue(HCkXml cHandle, const char *tagPath, const char *attrName, HCkString outStr); const char *CkXml_getChildAttrValue(HCkXml cHandle, const char *tagPath, const char *attrName);` |
| `GetChildBoolValue` | method | `BOOL CkXml_GetChildBoolValue(HCkXml cHandle, const char *tagPath);` |
| `GetChildContent` | method | `BOOL CkXml_GetChildContent(HCkXml cHandle, const char *tagPath, HCkString outStr); const char *CkXml_getChildContent(HCkXml cHandle, const char *tagPath);` |
| `GetChildContentByIndex` | method | `BOOL CkXml_GetChildContentByIndex(HCkXml cHandle, int index, HCkString outStr); const char *CkXml_getChildContentByIndex(HCkXml cHandle, int index);` |
| `GetChildContentSb` | method | `BOOL CkXml_GetChildContentSb(HCkXml cHandle, const char *tagPath, HCkStringBuilder sb);` |
| `GetChildExact` | method | `HCkXml CkXml_GetChildExact(HCkXml cHandle, const char *tag, const char *content);` |
| `GetChildIntValue` | method | `int CkXml_GetChildIntValue(HCkXml cHandle, const char *tagPath);` |
| `GetChildTag` | method | `BOOL CkXml_GetChildTag(HCkXml cHandle, int index, HCkString outStr); const char *CkXml_getChildTag(HCkXml cHandle, int index);` |
| `GetChildTagByIndex` | method | `BOOL CkXml_GetChildTagByIndex(HCkXml cHandle, int index, HCkString outStr); const char *CkXml_getChildTagByIndex(HCkXml cHandle, int index);` |
| `GetChildWithAttr` | method | `HCkXml CkXml_GetChildWithAttr(HCkXml cHandle, const char *tagPath, const char *attrName, const char *attrValue);` |
| `GetChildWithContent` | method | `HCkXml CkXml_GetChildWithContent(HCkXml cHandle, const char *content);` |
| `GetChildWithTag` | method | `HCkXml CkXml_GetChildWithTag(HCkXml cHandle, const char *tagPath);` |
| `GetChildWithTag2` | method | `BOOL CkXml_GetChildWithTag2(HCkXml cHandle, const char *tagPath);` |
| `GetNthChildWithTag` | method | `HCkXml CkXml_GetNthChildWithTag(HCkXml cHandle, const char *tag, int n);` |
| `GetNthChildWithTag2` | method | `BOOL CkXml_GetNthChildWithTag2(HCkXml cHandle, const char *tag, int n);` |
| `GetParent` | method | `HCkXml CkXml_GetParent(HCkXml cHandle);` |
| `GetParent2` | method | `BOOL CkXml_GetParent2(HCkXml cHandle);` |
| `GetRoot` | method | `HCkXml CkXml_GetRoot(HCkXml cHandle);` |
| `GetRoot2` | method | `void CkXml_GetRoot2(HCkXml cHandle);` |
| `GetSelf` | method | `HCkXml CkXml_GetSelf(HCkXml cHandle);` |
| `GetXml` | method | `BOOL CkXml_GetXml(HCkXml cHandle, HCkString outStr); const char *CkXml_getXml(HCkXml cHandle);` |
| `GetXmlBd` | method | `BOOL CkXml_GetXmlBd(HCkXml cHandle, HCkBinData bd);` |
| `GetXmlSb` | method | `BOOL CkXml_GetXmlSb(HCkXml cHandle, HCkStringBuilder sb);` |
| `HasAttribute` | method | `BOOL CkXml_HasAttribute(HCkXml cHandle, const char *name);` |
| `HasAttrWithValue` | method | `BOOL CkXml_HasAttrWithValue(HCkXml cHandle, const char *name, const char *value);` |
| `HasChildWithContent` | method | `BOOL CkXml_HasChildWithContent(HCkXml cHandle, const char *content);` |
| `HasChildWithTag` | method | `BOOL CkXml_HasChildWithTag(HCkXml cHandle, const char *tagPath);` |
| `HasChildWithTagAndContent` | method | `BOOL CkXml_HasChildWithTagAndContent(HCkXml cHandle, const char *tagPath, const char *content);` |
| `InsertChildTreeAfter` | method | `void CkXml_InsertChildTreeAfter(HCkXml cHandle, int index, HCkXml tree);` |
| `InsertChildTreeBefore` | method | `void CkXml_InsertChildTreeBefore(HCkXml cHandle, int index, HCkXml tree);` |
| `LastChild` | method | `HCkXml CkXml_LastChild(HCkXml cHandle);` |
| `LastChild2` | method | `BOOL CkXml_LastChild2(HCkXml cHandle);` |
| `LoadBd` | method | `BOOL CkXml_LoadBd(HCkXml cHandle, HCkBinData bd, BOOL autoTrim);` |
| `LoadSb` | method | `BOOL CkXml_LoadSb(HCkXml cHandle, HCkStringBuilder sb, BOOL autoTrim);` |
| `LoadXml` | method | `BOOL CkXml_LoadXml(HCkXml cHandle, const char *xmlData);` |
| `LoadXml2` | method | `BOOL CkXml_LoadXml2(HCkXml cHandle, const char *xmlData, BOOL autoTrim);` |
| `LoadXmlFile` | method | `BOOL CkXml_LoadXmlFile(HCkXml cHandle, const char *fileName);` |
| `LoadXmlFile2` | method | `BOOL CkXml_LoadXmlFile2(HCkXml cHandle, const char *fileName, BOOL autoTrim);` |
| `NewChild` | method | `HCkXml CkXml_NewChild(HCkXml cHandle, const char *tagPath, const char *content);` |
| `NewChild2` | method | `void CkXml_NewChild2(HCkXml cHandle, const char *tagPath, const char *content);` |
| `NewChildAfter` | method | `HCkXml CkXml_NewChildAfter(HCkXml cHandle, int index, const char *tag, const char *content);` |
| `NewChildBefore` | method | `HCkXml CkXml_NewChildBefore(HCkXml cHandle, int index, const char *tag, const char *content);` |
| `NewChildInt2` | method | `void CkXml_NewChildInt2(HCkXml cHandle, const char *tagPath, int value);` |
| `NextInTraversal2` | method | `BOOL CkXml_NextInTraversal2(HCkXml cHandle, HCkStringBuilder sbState);` |
| `NextSibling` | method | `HCkXml CkXml_NextSibling(HCkXml cHandle);` |
| `NextSibling2` | method | `BOOL CkXml_NextSibling2(HCkXml cHandle);` |
| `NumChildrenAt` | method | `int CkXml_NumChildrenAt(HCkXml cHandle, const char *tagPath);` |
| `NumChildrenHavingTag` | method | `int CkXml_NumChildrenHavingTag(HCkXml cHandle, const char *tag);` |
| `PreviousSibling` | method | `HCkXml CkXml_PreviousSibling(HCkXml cHandle);` |
| `PreviousSibling2` | method | `BOOL CkXml_PreviousSibling2(HCkXml cHandle);` |
| `PruneAttribute` | method | `int CkXml_PruneAttribute(HCkXml cHandle, const char *attrName);` |
| `PruneTag` | method | `int CkXml_PruneTag(HCkXml cHandle, const char *tag);` |
| `RemoveAllAttributes` | method | `BOOL CkXml_RemoveAllAttributes(HCkXml cHandle);` |
| `RemoveAllChildren` | method | `void CkXml_RemoveAllChildren(HCkXml cHandle);` |
| `RemoveAttribute` | method | `BOOL CkXml_RemoveAttribute(HCkXml cHandle, const char *name);` |
| `RemoveChild` | method | `void CkXml_RemoveChild(HCkXml cHandle, const char *tagPath);` |
| `RemoveChildByIndex` | method | `void CkXml_RemoveChildByIndex(HCkXml cHandle, int index);` |
| `RemoveChildWithContent` | method | `void CkXml_RemoveChildWithContent(HCkXml cHandle, const char *content);` |
| `RemoveFromTree` | method | `void CkXml_RemoveFromTree(HCkXml cHandle);` |
| `RemoveStyleSheet` | method | `int CkXml_RemoveStyleSheet(HCkXml cHandle, const char *attrName, const char *attrValue);` |
| `SaveBinaryContent` | method | `BOOL CkXml_SaveBinaryContent(HCkXml cHandle, const char *filename, BOOL unzipFlag, BOOL decryptFlag, const char *password);` |
| `SaveXml` | method | `BOOL CkXml_SaveXml(HCkXml cHandle, const char *fileName);` |
| `Scrub` | method | `void CkXml_Scrub(HCkXml cHandle, const char *directives);` |
| `SearchAllForContent` | method | `HCkXml CkXml_SearchAllForContent(HCkXml cHandle, HCkXml afterPtr, const char *contentPattern);` |
| `SearchAllForContent2` | method | `BOOL CkXml_SearchAllForContent2(HCkXml cHandle, HCkXml afterPtr, const char *contentPattern);` |
| `SearchForAttribute` | method | `HCkXml CkXml_SearchForAttribute(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *attr, const char *valuePattern);` |
| `SearchForAttribute2` | method | `BOOL CkXml_SearchForAttribute2(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *attr, const char *valuePattern);` |
| `SearchForContent` | method | `HCkXml CkXml_SearchForContent(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *contentPattern);` |
| `SearchForContent2` | method | `BOOL CkXml_SearchForContent2(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *contentPattern);` |
| `SearchForTag` | method | `HCkXml CkXml_SearchForTag(HCkXml cHandle, HCkXml afterPtr, const char *tag);` |
| `SearchForTag2` | method | `BOOL CkXml_SearchForTag2(HCkXml cHandle, HCkXml afterPtr, const char *tag);` |
| `SetBinaryContentBd` | method | `BOOL CkXml_SetBinaryContentBd(HCkXml cHandle, HCkBinData data, BOOL zipFlag, BOOL encryptFlag, const char *password);` |
| `SetBinaryContentFromFile` | method | `BOOL CkXml_SetBinaryContentFromFile(HCkXml cHandle, const char *filename, BOOL zipFlag, BOOL encryptFlag, const char *password);` |
| `SortByAttribute` | method | `void CkXml_SortByAttribute(HCkXml cHandle, const char *attrName, BOOL ascending);` |
| `SortByAttributeInt` | method | `void CkXml_SortByAttributeInt(HCkXml cHandle, const char *attrName, BOOL ascending);` |
| `SortByContent` | method | `void CkXml_SortByContent(HCkXml cHandle, BOOL ascending);` |
| `SortByTag` | method | `void CkXml_SortByTag(HCkXml cHandle, BOOL ascending);` |
| `SortRecordsByAttribute` | method | `void CkXml_SortRecordsByAttribute(HCkXml cHandle, const char *sortTag, const char *attrName, BOOL ascending);` |
| `SortRecordsByContent` | method | `void CkXml_SortRecordsByContent(HCkXml cHandle, const char *sortTag, BOOL ascending);` |
| `SortRecordsByContentInt` | method | `void CkXml_SortRecordsByContentInt(HCkXml cHandle, const char *sortTag, BOOL ascending);` |
| `SwapNode` | method | `BOOL CkXml_SwapNode(HCkXml cHandle, HCkXml node);` |
| `SwapTree` | method | `BOOL CkXml_SwapTree(HCkXml cHandle, HCkXml tree);` |
| `TagContent` | method | `BOOL CkXml_TagContent(HCkXml cHandle, const char *tagName, HCkString outStr); const char *CkXml_tagContent(HCkXml cHandle, const char *tagName);` |
| `TagEquals` | method | `BOOL CkXml_TagEquals(HCkXml cHandle, const char *tag);` |
| `TagIndex` | method | `int CkXml_TagIndex(HCkXml cHandle, const char *tagPath);` |
| `TagNsEquals` | method | `BOOL CkXml_TagNsEquals(HCkXml cHandle, const char *ns);` |
| `TagUnpEquals` | method | `BOOL CkXml_TagUnpEquals(HCkXml cHandle, const char *unprefixedTag);` |
| `UnzipContent` | method | `BOOL CkXml_UnzipContent(HCkXml cHandle);` |
| `UnzipTree` | method | `BOOL CkXml_UnzipTree(HCkXml cHandle);` |
| `UpdateAt` | method | `BOOL CkXml_UpdateAt(HCkXml cHandle, const char *tagPath, BOOL autoCreate, const char *value);` |
| `UpdateAttrAt` | method | `BOOL CkXml_UpdateAttrAt(HCkXml cHandle, const char *tagPath, BOOL autoCreate, const char *attrName, const char *attrValue);` |
| `UpdateAttribute` | method | `BOOL CkXml_UpdateAttribute(HCkXml cHandle, const char *attrName, const char *attrValue);` |
| `UpdateAttributeInt` | method | `BOOL CkXml_UpdateAttributeInt(HCkXml cHandle, const char *attrName, int value);` |
| `UpdateChildContent` | method | `void CkXml_UpdateChildContent(HCkXml cHandle, const char *tagPath, const char *value);` |
| `UpdateChildContentInt` | method | `void CkXml_UpdateChildContentInt(HCkXml cHandle, const char *tagPath, int value);` |
| `ZipContent` | method | `BOOL CkXml_ZipContent(HCkXml cHandle);` |
| `ZipTree` | method | `BOOL CkXml_ZipTree(HCkXml cHandle);` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### Xml.Cdata

`Chilkat 11.7.0 · c · Xml · Cdata · property · read/write`

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

Controls how this element's text content is emitted. When set to `TRUE`, the element content is written inside a CDATA section instead of being emitted as ordinary character data with XML escaping.

**CDATA and escaping:** CDATA is useful when text contains many characters such as `<` or `&`. It does not change the logical text value of the element; it only changes how that text is represented in the serialized XML.

### Xml.Content

`Chilkat 11.7.0 · c · Xml · Content · property · read/write`

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

Gets or sets the text content stored directly on this XML element. Child elements are not included in this value.

For example, both of the following elements have `This is the content` as their `Content`:

```
<tag1>This is the content</tag1>

<tag2><child1>abc</child1><child2>abc</child2>This is the content</tag2>
```

**Content vs. children:** Chilkat stores an element's direct text content separately from its child elements. Use the child-navigation methods when you need the nested elements themselves.

See also:

- [Content vs. Children: A common misconception explained.](https://www.chilkatsoft.com/p/p_472.asp)

### Xml.ContentInt

`Chilkat 11.7.0 · c · Xml · ContentInt · property · read/write`

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

Gets or sets this element's content as a 32-bit integer. Setting the property converts the integer to its decimal text representation; getting the property interprets the element's text content as an integer.

**Numeric content:** Use `Content` when the value may exceed the range of a 32-bit integer or when the exact lexical representation must be preserved.

### Xml.DocType

`Chilkat 11.7.0 · c · Xml · DocType · property · read/write`

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

Gets or sets the document type declaration associated with the XML document.

The value represents the document-level `DOCTYPE` declaration, for example `<!DOCTYPE note SYSTEM "note.dtd">`.

**Document-level setting:** Although this property may be accessed from any element reference in the tree, the DOCTYPE belongs to the XML document as a whole rather than to an individual element.

### Xml.EmitBom

`Chilkat 11.7.0 · c · Xml · EmitBom · property · read/write · since 9.5.0.44`

```c
BOOL CkXml_getEmitBom(HCkXml cHandle);
void CkXml_putEmitBom(HCkXml cHandle, BOOL newVal);
```

Controls whether a byte order mark (BOM, also called a preamble) is written when XML is saved to a file. The default is `FALSE`.

This setting is relevant to encodings for which a BOM can be emitted, such as UTF-8 and UTF-16. It does not affect XML returned as a language string by methods such as `GetXml`.

### Xml.EmitCompact

`Chilkat 11.7.0 · c · Xml · EmitCompact · property · read/write · since 9.5.0.64`

```c
BOOL CkXml_getEmitCompact(HCkXml cHandle);
void CkXml_putEmitCompact(HCkXml cHandle, BOOL newVal);
```

Controls whether XML emitted by `GetXml` and `GetXmlSb` is compact. When `TRUE`, unnecessary formatting whitespace and line breaks are omitted. The default is `FALSE` for backward compatibility.

**Formatting only:** Compact output changes presentation, not the XML tree or its element content.

### Xml.EmitXmlDecl

`Chilkat 11.7.0 · c · Xml · EmitXmlDecl · property · read/write`

```c
BOOL CkXml_getEmitXmlDecl(HCkXml cHandle);
void CkXml_putEmitXmlDecl(HCkXml cHandle, BOOL newVal);
```

Controls whether the XML declaration is included when XML is emitted. The default is `TRUE`. When set to `FALSE`, output methods such as `GetXml` and `SaveXml` omit the declaration.

An XML declaration is the leading construct such as `<?xml version="1.0" encoding="utf-8"?>`.

### Xml.Encoding

`Chilkat 11.7.0 · c · Xml · Encoding · property · read/write`

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

Gets or sets the `encoding` value used in the XML declaration. The default is `utf-8`. This is a document-level setting and may be accessed from any element in the tree.

When XML is loaded, Chilkat sets this property from the encoding declared by the input XML when one is present. If no encoding is declared, the property is reset to `utf-8`.

**Important:** Changing `Encoding` changes the declared/output encoding used when XML is serialized; it does not reinterpret or transcode the already-stored Unicode text inside the in-memory tree.

### Xml.I

`Chilkat 11.7.0 · c · Xml · I · property · read/write · since 9.5.0.64`

```c
int CkXml_getI(HCkXml cHandle);
void CkXml_putI(HCkXml cHandle, int newVal);
```

Provides a substitution value for `[i]` in Chilkat tag paths and `ChilkatPath` expressions. When a path contains `[i]`, the current value of this property is substituted for I.

**Loop-friendly paths:** The `I`, `J`, and `K` properties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.

### Xml.IsBase64

`Chilkat 11.7.0 · c · Xml · IsBase64 · property · read-only · since 9.5.0.76`

```c
BOOL CkXml_getIsBase64(HCkXml cHandle);
```

Returns `TRUE` if this element's content consists only of characters allowed in standard Base64 text, with whitespace ignored. Standard Base64 uses `A-Z`, `a-z`, `0-9`, `+`, `/`, and optional trailing `=` padding.

**Syntax check, not semantic validation:** A value can contain only Base64 characters and still not represent the data your application expects. This property is useful as a quick content-format test.

### Xml.J

`Chilkat 11.7.0 · c · Xml · J · property · read/write · since 9.5.0.64`

```c
int CkXml_getJ(HCkXml cHandle);
void CkXml_putJ(HCkXml cHandle, int newVal);
```

Provides a substitution value for `[j]` in Chilkat tag paths and `ChilkatPath` expressions. When a path contains `[j]`, the current value of this property is substituted for J.

**Loop-friendly paths:** The `I`, `J`, and `K` properties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.

### Xml.K

`Chilkat 11.7.0 · c · Xml · K · property · read/write · since 9.5.0.64`

```c
int CkXml_getK(HCkXml cHandle);
void CkXml_putK(HCkXml cHandle, int newVal);
```

Provides a substitution value for `[k]` in Chilkat tag paths and `ChilkatPath` expressions. When a path contains `[k]`, the current value of this property is substituted for K.

**Loop-friendly paths:** The `I`, `J`, and `K` properties make it convenient to reuse a path expression inside nested loops without constructing a new path string for every index.

### Xml.NumAttributes

`Chilkat 11.7.0 · c · Xml · NumAttributes · property · read-only`

```c
int CkXml_getNumAttributes(HCkXml cHandle);
```

Returns the number of attributes on this element.

For example, `<tag attr1="value1" attr2="value2">...</tag>` has two attributes. Attribute indexes used by methods such as `GetAttributeName` and `GetAttributeValue` are zero-based.

### Xml.NumChildren

`Chilkat 11.7.0 · c · Xml · NumChildren · property · read-only`

```c
int CkXml_getNumChildren(HCkXml cHandle);
```

Returns the number of direct child elements of this element. Descendants below those children are not included in the count.

**Direct children only:** Use traversal or search methods when you need to inspect the entire subtree rather than only the immediate children.

### Xml.SortCaseInsensitive

`Chilkat 11.7.0 · c · Xml · SortCaseInsensitive · property · read/write`

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

Controls case sensitivity for the XML sorting methods. Set to `TRUE` for case-insensitive string comparisons or `FALSE` for case-sensitive comparisons.

### Xml.Standalone

`Chilkat 11.7.0 · c · Xml · Standalone · property · read/write`

```c
BOOL CkXml_getStandalone(HCkXml cHandle);
void CkXml_putStandalone(HCkXml cHandle, BOOL newVal);
```

Controls the `standalone` pseudo-attribute in the XML declaration. This is a document-level setting and may be accessed from any element in the tree.

Setting this property to `TRUE` causes the declaration to include `standalone="yes"`.

**XML declaration:** The standalone declaration concerns whether the document relies on external markup declarations. It is metadata in the XML declaration; it does not by itself validate or alter the document.

### Xml.Strict

`Chilkat 11.7.0 · c · Xml · Strict · property · read/write · since 11.6.0`

```c
BOOL CkXml_getStrict(HCkXml cHandle);
void CkXml_putStrict(HCkXml cHandle, BOOL newVal);
```

When `Strict` is **true**, the XML loading methods first check that the input is well-formed XML. If it is not, the load fails and the contents of this Xml object are left **unchanged**. The default is `FALSE`.

This applies to `LoadXml`, `LoadXml2`, `LoadSb`, `LoadBd`, `LoadXmlFile` and `LoadXmlFile2`.

Chilkat's XML parser is deliberately tolerant. By default it can accept input that is not well-formed, succeed, and leave a partially populated tree. That is convenient when the goal is a best-effort parse of imperfect input, but it is the wrong behavior when a silently dropped element or attribute changes what the application does.

Set `Strict` to `TRUE` for XML carrying configuration, credentials, signed content, or security parameters, where an element that quietly failed to load would be acted on as though it had never been present.

The check is for XML 1.0 **well-formedness** only. It is not a validating parse: no DTD or schema is read, and the document is not checked against one. Markup declarations inside an internal DTD subset are skipped rather than parsed.

**Note:** The default is `FALSE` so that existing applications are unaffected. When a strict load is rejected, this Xml object keeps whatever it held before the call, so a failed reload never leaves the object empty.

### Xml.Tag

`Chilkat 11.7.0 · c · Xml · Tag · property · read/write`

```c
void CkXml_getTag(HCkXml cHandle, HCkString retval);
void CkXml_putTag(HCkXml cHandle, const char *newVal);
const char *CkXml_tag(HCkXml cHandle);
```

Gets or sets the element name for this element, including any namespace prefix. For example, the tag for `<soapenv:Body>` is `soapenv:Body`.

Use `TagNsPrefix` and `TagUnprefixed` when the prefix and local portion are needed separately.

### Xml.TagNsPrefix

`Chilkat 11.7.0 · c · Xml · TagNsPrefix · property · read/write · since 9.5.0.77`

```c
void CkXml_getTagNsPrefix(HCkXml cHandle, HCkString retval);
void CkXml_putTagNsPrefix(HCkXml cHandle, const char *newVal);
const char *CkXml_tagNsPrefix(HCkXml cHandle);
```

Gets or sets the namespace prefix portion of this element's tag. For `soapenv:Envelope`, the namespace prefix is `soapenv`.

**Prefix vs. namespace URI:** This property deals with the lexical prefix in the tag name. A prefix is not itself the namespace URI; namespace bindings are expressed through `xmlns` attributes in the XML.

### Xml.TagPath

`Chilkat 11.7.0 · c · Xml · TagPath · property · read-only · since 9.5.0.77`

```c
void CkXml_getTagPath(HCkXml cHandle, HCkString retval);
const char *CkXml_tagPath(HCkXml cHandle);
```

Returns the Chilkat tag path needed to reach this element from the document root. If this object currently references the root element, the returned path is the empty string.

**Not XPath:** A Chilkat tag path is Chilkat's own navigation syntax, typically using `|` between element names. It is not an XPath expression.

### Xml.TagUnprefixed

`Chilkat 11.7.0 · c · Xml · TagUnprefixed · property · read/write · since 9.5.0.77`

```c
void CkXml_getTagUnprefixed(HCkXml cHandle, HCkString retval);
void CkXml_putTagUnprefixed(HCkXml cHandle, const char *newVal);
const char *CkXml_tagUnprefixed(HCkXml cHandle);
```

Gets or sets the unprefixed portion of this element's tag. For `soapenv:Envelope`, the unprefixed tag is `Envelope`.

Use `TagNsPrefix` to access the prefix separately.

### Xml.TreeId

`Chilkat 11.7.0 · c · Xml · TreeId · property · read-only`

```c
int CkXml_getTreeId(HCkXml cHandle);
```

Returns the identifier of the XML tree to which this element belongs. Elements in the same XML document have the same `TreeId`.

**Useful for element references:** Multiple `Xml` objects can reference different elements in the same underlying tree. Comparing `TreeId` values is a convenient way to determine whether two element references belong to that same tree.

### Xml.UncommonOptions

`Chilkat 11.7.0 · c · Xml · UncommonOptions · property · read/write · since 9.5.0.90`

```c
void CkXml_getUncommonOptions(HCkXml cHandle, HCkString retval);
void CkXml_putUncommonOptions(HCkXml cHandle, const char *newVal);
const char *CkXml_uncommonOptions(HCkXml cHandle);
```

Provides a catch-all string for uncommon XML behaviors. The default is the empty string, which is appropriate for normal use.

Leave this property empty unless Chilkat documentation or support identifies a specific option needed for a specialized interoperability case.

## Methods

### Xml.AccumulateTagContent

`Chilkat 11.7.0 · c · Xml · AccumulateTagContent · method`

```c
BOOL CkXml_AccumulateTagContent(HCkXml cHandle, const char *tag, const char *skipTags, HCkString outStr);
const char *CkXml_accumulateTagContent(HCkXml cHandle, const char *tag, const char *skipTags);
```

Traverses the subtree rooted at the calling element and concatenates the text content of all elements whose tag equals `tag`.

`skipTags` is a vertical-bar-delimited list of tag names whose entire subtrees are excluded from the accumulation. For example, `script|style` skips elements rooted at either of those tags.

Returns TRUE for success, FALSE for failure.

### Xml.AddAttribute

`Chilkat 11.7.0 · c · Xml · AddAttribute · method`

```c
BOOL CkXml_AddAttribute(HCkXml cHandle, const char *name, const char *value);
```

Adds an attribute named `name` with the specified string `value` to the calling element.

Returns `TRUE` on success and `FALSE` on failure.

**When an attribute may already exist:** Use `AddOrUpdateAttribute` or `UpdateAttribute` when the desired behavior is to update an existing attribute value instead of requiring a new attribute.

Returns TRUE for success, FALSE for failure.

### Xml.AddAttributeInt

`Chilkat 11.7.0 · c · Xml · AddAttributeInt · method`

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

Adds an attribute named `name` whose value is the decimal representation of `value`.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.AddChildTree

`Chilkat 11.7.0 · c · Xml · AddChildTree · method`

```c
BOOL CkXml_AddChildTree(HCkXml cHandle, HCkXml tree);
```

Adds the entire XML subtree referenced by `tree` as a new direct child of the calling element.

If `tree` already belongs to another XML document, the subtree is transferred to the destination tree rather than copied as an unrelated duplicate.

**Tree ownership:** After moving a subtree between documents, its elements belong to the destination tree. `TreeId` can be used to determine which tree an element reference belongs to.

Returns TRUE for success, FALSE for failure.

### Xml.AddOrUpdateAttribute

`Chilkat 11.7.0 · c · Xml · AddOrUpdateAttribute · method`

```c
void CkXml_AddOrUpdateAttribute(HCkXml cHandle, const char *name, const char *value);
```

Sets the string value of an attribute on the calling element. If an attribute named `name` already exists, its value is replaced; otherwise the attribute is added.

### Xml.AddOrUpdateAttributeI

`Chilkat 11.7.0 · c · Xml · AddOrUpdateAttributeI · method`

```c
void CkXml_AddOrUpdateAttributeI(HCkXml cHandle, const char *name, int value);
```

Sets an integer-valued attribute on the calling element. If an attribute named `name` already exists, its value is replaced with the decimal representation of `value`; otherwise the attribute is added.

### Xml.AddStyleSheet

`Chilkat 11.7.0 · c · Xml · AddStyleSheet · method`

```c
void CkXml_AddStyleSheet(HCkXml cHandle, const char *styleSheet);
```

Adds an XML stylesheet processing instruction to the document. Pass the complete processing-instruction text, for example:

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

**Processing instruction:** An XML stylesheet declaration associates stylesheet metadata with the XML document; it does not apply or execute the stylesheet.

### Xml.AddToAttribute

`Chilkat 11.7.0 · c · Xml · AddToAttribute · method`

```c
void CkXml_AddToAttribute(HCkXml cHandle, const char *name, int amount);
```

Treats the named attribute value as an integer, adds `amount`, and stores the resulting integer back in the attribute.

If the attribute does not yet exist, this method behaves like `AddOrUpdateAttributeI` and creates it with `amount` as the value.

### Xml.AddToChildContent

`Chilkat 11.7.0 · c · Xml · AddToChildContent · method`

```c
void CkXml_AddToChildContent(HCkXml cHandle, const char *tag, int amount);
```

Finds the child identified by `tag`, interprets its content as an integer, adds `amount`, and stores the resulting integer as the child's new content.

### Xml.AddToContent

`Chilkat 11.7.0 · c · Xml · AddToContent · method`

```c
void CkXml_AddToContent(HCkXml cHandle, int amount);
```

Interprets this element's content as an integer, adds `amount`, and stores the resulting integer as the new content.

### Xml.AppendToContent

`Chilkat 11.7.0 · c · Xml · AppendToContent · method`

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

Appends `str` to the existing text content of the calling element without replacing its child elements.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.ChildContentMatches

`Chilkat 11.7.0 · c · Xml · ChildContentMatches · method`

```c
BOOL CkXml_ChildContentMatches(HCkXml cHandle, const char *tagPath, const char *pattern, BOOL caseSensitive);
```

Returns `TRUE` if the child identified by `tagPath` has content matching `pattern`; otherwise returns `FALSE`. `caseSensitive` controls whether letter case is significant.

The pattern may contain `*` wildcards, where each asterisk matches zero or more characters.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.ChilkatPath

`Chilkat 11.7.0 · c · Xml · ChilkatPath · method`

```c
BOOL CkXml_ChilkatPath(HCkXml cHandle, const char *pathCmd, HCkString outStr);
const char *CkXml_chilkatPath(HCkXml cHandle, const char *pathCmd);
```

Evaluates a Chilkat-specific path command that can navigate from the current element, return element content or an attribute value, or move the caller's internal element reference.

**This syntax is not XPath.** Commands are separated by vertical bars and the expression ends with a return command:

```
command|command|command|...|returnCommand
```

Navigation commands include:

- `TagName` - first direct child having that tag.
- `TagName[n]` - the indexed direct child having that tag.
- `..` - parent.
- `++` / `--` - next / previous sibling.
- `TagName{Content}` - first direct child with that tag and exact content.
- `/T/TagName` - traverse the subtree and find the first element with that tag.
- `/C/TagName,ContentPattern` - traverse for a tag whose content matches a wildcard pattern.
- `/C/ContentPattern` - traverse for any tag whose content matches a wildcard pattern.
- `/A/TagName,AttrName,AttrValuePattern` - traverse for a tag having a matching attribute value.

The final return command is:

- `*` - return the current element's content.
- `(AttrName)` - return an attribute value.
- `$` - move this `Xml` object to the selected element and return an empty string.

**Index substitution:** The `I`, `J`, and `K` properties can be used with `[i]`, `[j]`, and `[k]` in path expressions.

Returns TRUE for success, FALSE for failure.

### Xml.Clear

`Chilkat 11.7.0 · c · Xml · Clear · method`

```c
void CkXml_Clear(HCkXml cHandle);
```

Clears the calling element by removing all child elements, attributes, and text content, and resets its tag name to `unnamed`.

The element itself remains in the tree; this method clears its contents rather than removing the element from its parent.

### Xml.ContentMatches

`Chilkat 11.7.0 · c · Xml · ContentMatches · method`

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

Returns `TRUE` if this element's content matches `pattern`; otherwise returns `FALSE`. `caseSensitive` controls whether letter case is significant.

The pattern may contain `*` wildcards, where each asterisk matches zero or more characters.

### Xml.Copy

`Chilkat 11.7.0 · c · Xml · Copy · method`

```c
void CkXml_Copy(HCkXml cHandle, HCkXml node);
```

Copies the `Tag`, `Content`, and attributes from `node` to the calling element.

**Not a subtree copy:** This method does not copy the source element's children. Use a tree-oriented method such as `AddChildTree` or `SwapTree` when child structure is part of the operation.

### Xml.CopyRef

`Chilkat 11.7.0 · c · Xml · CopyRef · method`

```c
void CkXml_CopyRef(HCkXml cHandle, HCkXml copyFromNode);
```

Changes this `Xml` object so that it references the same underlying XML element as `copyFromNode`. The caller's previous element reference is discarded.

**Reference operation:** `CopyRef` does not copy XML data. After the call, both `Xml` objects refer to the same element, so edits through either reference affect the same tree element.

### Xml.DecodeEntities

`Chilkat 11.7.0 · c · Xml · DecodeEntities · method`

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

Decodes HTML character entities found in `str` and returns the decoded text. This is a utility operation; it does not modify the XML tree unless the returned string is assigned to an element.

For example, an HTML entity such as `&amp;` is decoded to `&`.

Returns TRUE for success, FALSE for failure.

### Xml.DecryptContent

`Chilkat 11.7.0 · c · Xml · DecryptContent · method`

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

Decrypts element content previously produced by `EncryptContent`, using the same password, and restores the original plaintext content.

Returns `TRUE` on success and `FALSE` on failure.

**Compatibility-oriented encryption:** This method is paired specifically with `EncryptContent`. It is not a general XML Encryption (XML-Enc) implementation.

Returns TRUE for success, FALSE for failure.

### Xml.EncryptContent

`Chilkat 11.7.0 · c · Xml · EncryptContent · method`

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

Encrypts the calling element's text content using Chilkat's password-based 128-bit AES-CBC format and replaces the plaintext content with Base64-encoded encrypted data.

Returns `TRUE` on success and `FALSE` on failure.

**Scope:** Only this element's content is encrypted. The tag, attributes, and child elements are not encrypted by this method. Use `DecryptContent` with the same password to restore the content.

Returns TRUE for success, FALSE for failure.

### Xml.ExtractChildByIndex

`Chilkat 11.7.0 · c · Xml · ExtractChildByIndex · method`

```c
HCkXml CkXml_ExtractChildByIndex(HCkXml cHandle, int index);
```

Removes the direct child at zero-based `index` from the calling element and returns an `Xml` object for the detached child subtree.

**Extract vs. remove:** Unlike `RemoveChildByIndex`, extraction gives the caller a reference to the removed subtree so it can be retained, inspected, or attached elsewhere.

Returns `NULL` on failure

### Xml.ExtractChildByName

`Chilkat 11.7.0 · c · Xml · ExtractChildByName · method`

```c
HCkXml CkXml_ExtractChildByName(HCkXml cHandle, const char *tagPath, const char *attrName, const char *attrValue);
```

Finds, removes, and returns the first child selected by `tagPath` and the optional attribute criteria.

If `attrName` and `attrValue` are empty, the first child matching the tag/path is extracted. If `attrName` is provided, the child must have that attribute. If `attrValue` is also provided, the attribute value must match exactly.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns `NULL` on failure

### Xml.FindChild

`Chilkat 11.7.0 · c · Xml · FindChild · method`

```c
HCkXml CkXml_FindChild(HCkXml cHandle, const char *tagPath);
```

Returns an `Xml` object referencing the child selected by `tagPath`. The calling object remains positioned on its current element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.FindChild2

`Chilkat 11.7.0 · c · Xml · FindChild2 · method`

```c
BOOL CkXml_FindChild2(HCkXml cHandle, const char *tagPath);
```

Moves the calling `Xml` object's internal reference to the child selected by `tagPath`. Returns `TRUE` when the child is found and the move succeeds; otherwise returns `FALSE`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.FindNextRecord

`Chilkat 11.7.0 · c · Xml · FindNextRecord · method`

```c
HCkXml CkXml_FindNextRecord(HCkXml cHandle, const char *tagPath, const char *contentPattern);
```

Finds the next direct child record for which the descendant identified by `tagPath` has content matching `contentPattern`. This is intended for iterating record-like child elements.

The content pattern may contain `*` wildcards.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns `NULL` on failure

### Xml.FindOrAddNewChild

`Chilkat 11.7.0 · c · Xml · FindOrAddNewChild · method`

```c
HCkXml CkXml_FindOrAddNewChild(HCkXml cHandle, const char *tagPath);
```

Returns the child selected by `tagPath` if it already exists. If it does not exist, creates the required child path with empty content and returns the resulting child element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath. Use `NewChild` instead when duplicate children with the same tag are intentional.

Returns `NULL` on failure

### Xml.FirstChild

`Chilkat 11.7.0 · c · Xml · FirstChild · method`

```c
HCkXml CkXml_FirstChild(HCkXml cHandle);
```

Returns an `Xml` object referencing the first direct child of the calling element.

A common forward-iteration pattern is `FirstChild` followed by repeated calls to `NextSibling`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.FirstChild2

`Chilkat 11.7.0 · c · Xml · FirstChild2 · method`

```c
BOOL CkXml_FirstChild2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to its first direct child. Returns `TRUE` if a first child exists; otherwise returns `FALSE`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.GetAttributeName

`Chilkat 11.7.0 · c · Xml · GetAttributeName · method`

```c
BOOL CkXml_GetAttributeName(HCkXml cHandle, int index, HCkString outStr);
const char *CkXml_getAttributeName(HCkXml cHandle, int index);
```

Returns the name of the attribute at zero-based `index`. Use `NumAttributes` to determine the valid index range.

Returns TRUE for success, FALSE for failure.

### Xml.GetAttributeValue

`Chilkat 11.7.0 · c · Xml · GetAttributeValue · method`

```c
BOOL CkXml_GetAttributeValue(HCkXml cHandle, int index, HCkString outStr);
const char *CkXml_getAttributeValue(HCkXml cHandle, int index);
```

Returns the value of the attribute at zero-based `index`. Use `NumAttributes` to determine the valid index range.

Returns TRUE for success, FALSE for failure.

### Xml.GetAttributeValueInt

`Chilkat 11.7.0 · c · Xml · GetAttributeValueInt · method`

```c
int CkXml_GetAttributeValueInt(HCkXml cHandle, int index);
```

Returns the value of the attribute at zero-based `index`, interpreted as a 32-bit integer.

### Xml.GetAttrValue

`Chilkat 11.7.0 · c · Xml · GetAttrValue · method`

```c
BOOL CkXml_GetAttrValue(HCkXml cHandle, const char *name, HCkString outStr);
const char *CkXml_getAttrValue(HCkXml cHandle, const char *name);
```

Returns the value of the attribute named `name` on the calling element.

Use `HasAttribute` when the application must distinguish a missing attribute from an attribute whose value is empty.

Returns TRUE for success, FALSE for failure.

### Xml.GetAttrValueInt

`Chilkat 11.7.0 · c · Xml · GetAttrValueInt · method`

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

Returns the value of the attribute named `name` interpreted as a 32-bit integer. Returns `0` if the attribute does not exist.

**Ambiguous zero:** Because a missing attribute and an attribute containing zero can both yield `0`, call `HasAttribute` first when that distinction matters.

### Xml.GetChild

`Chilkat 11.7.0 · c · Xml · GetChild · method`

```c
HCkXml CkXml_GetChild(HCkXml cHandle, int index);
```

Returns an `Xml` object referencing the direct child at zero-based `index`. The calling object remains positioned on its current element.

Use `NumChildren` to determine the valid child range.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.GetChild2

`Chilkat 11.7.0 · c · Xml · GetChild2 · method`

```c
BOOL CkXml_GetChild2(HCkXml cHandle, int index);
```

Moves the calling `Xml` object's internal reference to the direct child at zero-based `index`. Returns `TRUE` on success and `FALSE` if the child cannot be selected.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.GetChildAttrValue

`Chilkat 11.7.0 · c · Xml · GetChildAttrValue · method · since 9.5.0.77`

```c
BOOL CkXml_GetChildAttrValue(HCkXml cHandle, const char *tagPath, const char *attrName, HCkString outStr);
const char *CkXml_getChildAttrValue(HCkXml cHandle, const char *tagPath, const char *attrName);
```

Returns the value of attribute `attrName` on the descendant element selected by `tagPath`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildBoolValue

`Chilkat 11.7.0 · c · Xml · GetChildBoolValue · method`

```c
BOOL CkXml_GetChildBoolValue(HCkXml cHandle, const char *tagPath);
```

Returns the integer content of the child selected by `tagPath` as a Boolean value: content equal to `0` yields `FALSE`; a non-zero integer yields `TRUE`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.GetChildContent

`Chilkat 11.7.0 · c · Xml · GetChildContent · method`

```c
BOOL CkXml_GetChildContent(HCkXml cHandle, const char *tagPath, HCkString outStr);
const char *CkXml_getChildContent(HCkXml cHandle, const char *tagPath);
```

Returns the text content of the child selected by `tagPath`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Content only:** The returned value is the child element's direct `Content`; nested child elements are not serialized into this string.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildContentByIndex

`Chilkat 11.7.0 · c · Xml · GetChildContentByIndex · method`

```c
BOOL CkXml_GetChildContentByIndex(HCkXml cHandle, int index, HCkString outStr);
const char *CkXml_getChildContentByIndex(HCkXml cHandle, int index);
```

Returns the text content of the direct child at zero-based `index`. Use `NumChildren` to determine the valid range.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildContentSb

`Chilkat 11.7.0 · c · Xml · GetChildContentSb · method · since 9.5.0.76`

```c
BOOL CkXml_GetChildContentSb(HCkXml cHandle, const char *tagPath, HCkStringBuilder sb);
```

Finds the element selected by `tagPath` and appends that element's text content to `sb`.

The existing contents of the `StringBuilder` are preserved.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildExact

`Chilkat 11.7.0 · c · Xml · GetChildExact · method`

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

Returns the first direct child whose tag equals `tag` and whose text content exactly equals `content`.

The calling object remains positioned on its current element.

Returns `NULL` on failure

### Xml.GetChildIntValue

`Chilkat 11.7.0 · c · Xml · GetChildIntValue · method`

```c
int CkXml_GetChildIntValue(HCkXml cHandle, const char *tagPath);
```

**Full documentation for this method (same in every language):** [Workaround for 32-bit Integer Limitations (+/- 2GB)](https://www.chilkatsoft.com/ai-docs/v/11.7.0/articles/xml_GetChildIntValue_32_bit_limitation.md)

Returns the content of the child selected by `tagPath`, interpreted as a 32-bit integer.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Integer range:** Use `GetChildContent` and parse the returned text separately when values may exceed the range of a 32-bit integer.

### Xml.GetChildTag

`Chilkat 11.7.0 · c · Xml · GetChildTag · method`

```c
BOOL CkXml_GetChildTag(HCkXml cHandle, int index, HCkString outStr);
const char *CkXml_getChildTag(HCkXml cHandle, int index);
```

Returns the tag name of the direct child at zero-based `index`. Use `NumChildren` to determine the valid index range.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildTagByIndex

`Chilkat 11.7.0 · c · Xml · GetChildTagByIndex · method`

```c
BOOL CkXml_GetChildTagByIndex(HCkXml cHandle, int index, HCkString outStr);
const char *CkXml_getChildTagByIndex(HCkXml cHandle, int index);
```

Returns the tag name of the direct child at zero-based `index`. Use `NumChildren` to determine the valid index range.

Returns TRUE for success, FALSE for failure.

### Xml.GetChildWithAttr

`Chilkat 11.7.0 · c · Xml · GetChildWithAttr · method`

```c
HCkXml CkXml_GetChildWithAttr(HCkXml cHandle, const char *tagPath, const char *attrName, const char *attrValue);
```

Returns the child selected by `tagPath` that also has an attribute named `attrName` whose value exactly equals `attrValue`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns `NULL` on failure

### Xml.GetChildWithContent

`Chilkat 11.7.0 · c · Xml · GetChildWithContent · method`

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

Returns the first direct child whose text content exactly equals `content`. The child tag may be any value.

Returns `NULL` on failure

### Xml.GetChildWithTag

`Chilkat 11.7.0 · c · Xml · GetChildWithTag · method`

```c
HCkXml CkXml_GetChildWithTag(HCkXml cHandle, const char *tagPath);
```

Returns an `Xml` object referencing the child selected by `tagPath`. The calling object remains positioned on its current element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.GetChildWithTag2

`Chilkat 11.7.0 · c · Xml · GetChildWithTag2 · method · since 11.1.0`

```c
BOOL CkXml_GetChildWithTag2(HCkXml cHandle, const char *tagPath);
```

Moves the calling `Xml` object's internal reference to the child selected by `tagPath`. Returns `TRUE` when the child is found and the move succeeds; otherwise returns `FALSE`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.GetNthChildWithTag

`Chilkat 11.7.0 · c · Xml · GetNthChildWithTag · method`

```c
HCkXml CkXml_GetNthChildWithTag(HCkXml cHandle, const char *tag, int n);
```

Returns the zero-based `n`th direct child whose tag exactly equals `tag`. Children with other tag names are ignored when counting matches.

Use `NumChildrenHavingTag` to determine how many matching children are available.

Returns `NULL` on failure

### Xml.GetNthChildWithTag2

`Chilkat 11.7.0 · c · Xml · GetNthChildWithTag2 · method`

```c
BOOL CkXml_GetNthChildWithTag2(HCkXml cHandle, const char *tag, int n);
```

Moves the calling `Xml` object's internal reference to the zero-based `n`th direct child whose tag equals `tag`. Returns `TRUE` on success and `FALSE` when no such child exists.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.GetParent

`Chilkat 11.7.0 · c · Xml · GetParent · method`

```c
HCkXml CkXml_GetParent(HCkXml cHandle);
```

Returns an `Xml` object referencing this element's parent. Returns no parent when the current element is the document root.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.GetParent2

`Chilkat 11.7.0 · c · Xml · GetParent2 · method`

```c
BOOL CkXml_GetParent2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to its parent. Returns `TRUE` if a parent exists; otherwise returns `FALSE` when already at the root.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.GetRoot

`Chilkat 11.7.0 · c · Xml · GetRoot · method`

```c
HCkXml CkXml_GetRoot(HCkXml cHandle);
```

Returns an `Xml` object referencing the root element of the XML tree that contains the current element. The calling object remains positioned on its current element.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.GetRoot2

`Chilkat 11.7.0 · c · Xml · GetRoot2 · method`

```c
void CkXml_GetRoot2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to the root element of its XML tree.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.GetSelf

`Chilkat 11.7.0 · c · Xml · GetSelf · method`

```c
HCkXml CkXml_GetSelf(HCkXml cHandle);
```

Returns a new `Xml` object that references the same underlying XML element as the calling object.

**Shared element reference:** This is not a deep copy. Both objects reference the same element, so changes made through either object are changes to the same XML tree.

Returns `NULL` on failure

### Xml.GetXml

`Chilkat 11.7.0 · c · Xml · GetXml · method`

```c
BOOL CkXml_GetXml(HCkXml cHandle, HCkString outStr);
const char *CkXml_getXml(HCkXml cHandle);
```

Serializes the XML tree or subtree rooted at the current element and returns the XML text.

When called while positioned on the document root, the XML declaration is included if `EmitXmlDecl` is `TRUE`. When called on a non-root element, only that subtree is emitted and the document declaration is not included.

`EmitCompact`, `Encoding`, `Standalone`, and related document/output properties affect serialization as applicable.

**String vs. bytes:** A language string is Unicode text. The `Encoding` declaration describes serialized XML encoding, while actual byte encoding matters when XML is written to a file or byte-oriented destination.

Returns TRUE for success, FALSE for failure.

### Xml.GetXmlBd

`Chilkat 11.7.0 · c · Xml · GetXmlBd · method · since 9.5.0.77`

```c
BOOL CkXml_GetXmlBd(HCkXml cHandle, HCkBinData bd);
```

Serializes the XML tree or subtree rooted at the current element and appends the encoded XML bytes to `bd`.

The existing contents of the `BinData` object are preserved. The XML output encoding is governed by the XML document's output settings, including `Encoding`.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.GetXmlSb

`Chilkat 11.7.0 · c · Xml · GetXmlSb · method · since 9.5.0.62`

```c
BOOL CkXml_GetXmlSb(HCkXml cHandle, HCkStringBuilder sb);
```

Serializes the XML tree or subtree rooted at the current element and appends the resulting XML text to `sb`.

The existing contents of `sb` are preserved. Output properties such as `EmitCompact` and `EmitXmlDecl` apply as appropriate.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.HasAttribute

`Chilkat 11.7.0 · c · Xml · HasAttribute · method`

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

Returns `TRUE` if the calling element has an attribute named `name`; otherwise returns `FALSE`.

### Xml.HasAttrWithValue

`Chilkat 11.7.0 · c · Xml · HasAttrWithValue · method`

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

Returns `TRUE` if the calling element has an attribute named `name` whose value exactly equals `value`; otherwise returns `FALSE`.

### Xml.HasChildWithContent

`Chilkat 11.7.0 · c · Xml · HasChildWithContent · method`

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

Returns `TRUE` if any direct child has text content exactly equal to `content`; otherwise returns `FALSE`.

### Xml.HasChildWithTag

`Chilkat 11.7.0 · c · Xml · HasChildWithTag · method`

```c
BOOL CkXml_HasChildWithTag(HCkXml cHandle, const char *tagPath);
```

Returns `TRUE` if the child selected by `tagPath` exists; otherwise returns `FALSE`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.HasChildWithTagAndContent

`Chilkat 11.7.0 · c · Xml · HasChildWithTagAndContent · method`

```c
BOOL CkXml_HasChildWithTagAndContent(HCkXml cHandle, const char *tagPath, const char *content);
```

Returns `TRUE` if the child selected by `tagPath` exists and its text content exactly equals `content`; otherwise returns `FALSE`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.InsertChildTreeAfter

`Chilkat 11.7.0 · c · Xml · InsertChildTreeAfter · method`

```c
void CkXml_InsertChildTreeAfter(HCkXml cHandle, int index, HCkXml tree);
```

Inserts the entire subtree referenced by `tree` as a direct child immediately after the existing child at zero-based `index`.

If `tree` belongs to another XML document, the subtree is transferred to the destination tree.

**Structural move:** The operation preserves the subtree structure. The supplied tree is not flattened into text content.

### Xml.InsertChildTreeBefore

`Chilkat 11.7.0 · c · Xml · InsertChildTreeBefore · method`

```c
void CkXml_InsertChildTreeBefore(HCkXml cHandle, int index, HCkXml tree);
```

Inserts the entire subtree referenced by `tree` as a direct child immediately before the existing child at zero-based `index`.

If `tree` belongs to another XML document, the subtree is transferred to the destination tree.

**Structural move:** The operation preserves the subtree structure. The supplied tree is not flattened into text content.

### Xml.LastChild

`Chilkat 11.7.0 · c · Xml · LastChild · method`

```c
HCkXml CkXml_LastChild(HCkXml cHandle);
```

Returns an `Xml` object referencing the last direct child of the calling element.

A common reverse-iteration pattern is `LastChild` followed by repeated calls to `PreviousSibling`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.LastChild2

`Chilkat 11.7.0 · c · Xml · LastChild2 · method`

```c
BOOL CkXml_LastChild2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to its last direct child. Returns `TRUE` if a last child exists; otherwise returns `FALSE`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.LoadBd

`Chilkat 11.7.0 · c · Xml · LoadBd · method · since 9.5.0.77`

```c
BOOL CkXml_LoadBd(HCkXml cHandle, HCkBinData bd, BOOL autoTrim);
```

Parses XML from the bytes contained in `bd` and replaces the calling object's current XML tree with the loaded document.

If `autoTrim` is `TRUE`, leading and trailing whitespace is removed from each leaf element's text content during loading.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.LoadSb

`Chilkat 11.7.0 · c · Xml · LoadSb · method · since 9.5.0.62`

```c
BOOL CkXml_LoadSb(HCkXml cHandle, HCkStringBuilder sb, BOOL autoTrim);
```

Parses XML from the current contents of `sb` and replaces the calling object's current XML tree with the loaded document.

If `autoTrim` is `TRUE`, leading and trailing whitespace is removed from each leaf element's text content while loading.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.LoadXml

`Chilkat 11.7.0 · c · Xml · LoadXml · method`

```c
BOOL CkXml_LoadXml(HCkXml cHandle, const char *xmlData);
```

Parses the XML text in `xmlData` and replaces the calling object's current XML tree content with the loaded document root. Returns `TRUE` if parsing succeeds.

**Replacement operation:** A successful load replaces the current document/tree state represented by this object; it does not append the loaded XML beneath the current element.

Returns TRUE for success, FALSE for failure.

### Xml.LoadXml2

`Chilkat 11.7.0 · c · Xml · LoadXml2 · method`

```c
BOOL CkXml_LoadXml2(HCkXml cHandle, const char *xmlData, BOOL autoTrim);
```

Parses the XML text in `xmlData` and replaces the current XML tree, like `LoadXml`. The `autoTrim` argument additionally controls whether leading and trailing whitespace is removed from each leaf element's text content while loading.

**Whitespace significance:** Set `autoTrim` to `FALSE` when leading or trailing text whitespace is significant to the application.

Returns TRUE for success, FALSE for failure.

### Xml.LoadXmlFile

`Chilkat 11.7.0 · c · Xml · LoadXmlFile · method`

```c
BOOL CkXml_LoadXmlFile(HCkXml cHandle, const char *fileName);
```

Reads and parses an XML document from `fileName`, replacing the calling object's current XML tree with the loaded document root. Returns `TRUE` on success.

The file's XML declaration and byte encoding are used as part of normal XML parsing.

Returns TRUE for success, FALSE for failure.

### Xml.LoadXmlFile2

`Chilkat 11.7.0 · c · Xml · LoadXmlFile2 · method`

```c
BOOL CkXml_LoadXmlFile2(HCkXml cHandle, const char *fileName, BOOL autoTrim);
```

Reads and parses an XML document from `fileName`, replacing the current XML tree. The `autoTrim` argument controls whether leading and trailing whitespace is removed from each leaf element's text content.

**Whitespace significance:** Set `autoTrim` to `FALSE` when leading or trailing text whitespace must be preserved exactly.

Returns TRUE for success, FALSE for failure.

### Xml.NewChild

`Chilkat 11.7.0 · c · Xml · NewChild · method`

```c
HCkXml CkXml_NewChild(HCkXml cHandle, const char *tagPath, const char *content);
```

Creates and returns a new child at `tagPath` with the specified text `content`. A new child is created even when a child with the same tag already exists.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath. Intermediate elements in a multi-part path are created as needed. Use `FindOrAddNewChild` when duplicate final children should be avoided.

Returns `NULL` on failure

### Xml.NewChild2

`Chilkat 11.7.0 · c · Xml · NewChild2 · method`

```c
void CkXml_NewChild2(HCkXml cHandle, const char *tagPath, const char *content);
```

Creates a new child at `tagPath` with the specified text `content`, but does not return a separate `Xml` object for the new element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath. Intermediate elements in a multi-part path are created as needed.

### Xml.NewChildAfter

`Chilkat 11.7.0 · c · Xml · NewChildAfter · method`

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

Creates a new direct child with the specified `tag` and `content`, inserts it immediately after the child at zero-based `index`, and returns the new child element.

Returns `NULL` on failure

### Xml.NewChildBefore

`Chilkat 11.7.0 · c · Xml · NewChildBefore · method`

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

Creates a new direct child with the specified `tag` and `content`, inserts it immediately before the child at zero-based `index`, and returns the new child element.

Returns `NULL` on failure

### Xml.NewChildInt2

`Chilkat 11.7.0 · c · Xml · NewChildInt2 · method`

```c
void CkXml_NewChildInt2(HCkXml cHandle, const char *tagPath, int value);
```

Creates a new child at `tagPath` whose content is the decimal representation of `value`. No separate child object is returned.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath. Intermediate elements in a multi-part path are created as needed.

### Xml.NextInTraversal2

`Chilkat 11.7.0 · c · Xml · NextInTraversal2 · method · since 9.5.0.77`

```c
BOOL CkXml_NextInTraversal2(HCkXml cHandle, HCkStringBuilder sbState);
```

Moves the calling `Xml` object to the next element in a depth-first traversal of the tree and updates `sbState` with the traversal state.

Pass an empty `StringBuilder` when beginning a traversal, then reuse the same `sbState` for each subsequent call.

**Why the name ends in 2:** This method changes the caller's internal element reference. There is no separate `NextInTraversal` method that returns another `Xml` object.

### Xml.NextSibling

`Chilkat 11.7.0 · c · Xml · NextSibling · method`

```c
HCkXml CkXml_NextSibling(HCkXml cHandle);
```

Returns an `Xml` object referencing the current element's next sibling, or no object when there is no next sibling.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.NextSibling2

`Chilkat 11.7.0 · c · Xml · NextSibling2 · method`

```c
BOOL CkXml_NextSibling2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to its next sibling. Returns `TRUE` if one exists; otherwise returns `FALSE`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.NumChildrenAt

`Chilkat 11.7.0 · c · Xml · NumChildrenAt · method · since 9.5.0.64`

```c
int CkXml_NumChildrenAt(HCkXml cHandle, const char *tagPath);
```

Returns the number of direct children of the element selected by `tagPath`. Returns `-1` if the path does not identify an existing element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.NumChildrenHavingTag

`Chilkat 11.7.0 · c · Xml · NumChildrenHavingTag · method`

```c
int CkXml_NumChildrenHavingTag(HCkXml cHandle, const char *tag);
```

Returns the number of direct children whose tag exactly equals `tag`. Descendants below those children are not included.

### Xml.PreviousSibling

`Chilkat 11.7.0 · c · Xml · PreviousSibling · method`

```c
HCkXml CkXml_PreviousSibling(HCkXml cHandle);
```

Returns an `Xml` object referencing the current element's previous sibling, or no object when there is no previous sibling.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns `NULL` on failure

### Xml.PreviousSibling2

`Chilkat 11.7.0 · c · Xml · PreviousSibling2 · method`

```c
BOOL CkXml_PreviousSibling2(HCkXml cHandle);
```

Moves the calling `Xml` object's internal reference to its previous sibling. Returns `TRUE` if one exists; otherwise returns `FALSE`.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

See also:

- [More information about XML methods ending in "2"](http://www.cknotes.com/?p=41)

### Xml.PruneAttribute

`Chilkat 11.7.0 · c · Xml · PruneAttribute · method · since 9.5.0.77`

```c
int CkXml_PruneAttribute(HCkXml cHandle, const char *attrName);
```

Recursively traverses the subtree rooted at the calling element and removes every occurrence of the attribute named `attrName`.

Returns the number of attributes removed.

### Xml.PruneTag

`Chilkat 11.7.0 · c · Xml · PruneTag · method · since 9.5.0.77`

```c
int CkXml_PruneTag(HCkXml cHandle, const char *tag);
```

Recursively traverses the subtree rooted at the calling element and removes every element whose tag equals `tag`. Each removed element's entire descendant subtree is removed with it.

Returns the number of matching tag occurrences removed.

**Subtree pruning:** When a matching parent is removed, its descendants disappear as part of that subtree; this method is intended for structural cleanup rather than text-only removal.

### Xml.RemoveAllAttributes

`Chilkat 11.7.0 · c · Xml · RemoveAllAttributes · method`

```c
BOOL CkXml_RemoveAllAttributes(HCkXml cHandle);
```

Removes every attribute from the calling element. Returns `TRUE` on success.

Returns TRUE for success, FALSE for failure.

### Xml.RemoveAllChildren

`Chilkat 11.7.0 · c · Xml · RemoveAllChildren · method`

```c
void CkXml_RemoveAllChildren(HCkXml cHandle);
```

Removes all direct child elements and their subtrees from the calling element. The calling element's own tag, attributes, and text content are retained.

### Xml.RemoveAttribute

`Chilkat 11.7.0 · c · Xml · RemoveAttribute · method`

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

Removes the attribute named `name` from the calling element. Returns `TRUE` when the operation succeeds.

Returns TRUE for success, FALSE for failure.

### Xml.RemoveChild

`Chilkat 11.7.0 · c · Xml · RemoveChild · method`

```c
void CkXml_RemoveChild(HCkXml cHandle, const char *tagPath);
```

Removes all child elements selected by `tagPath` beneath the calling element.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**All matches:** This method removes matching children rather than returning a removed subtree. Use an `ExtractChild...` method when the removed element must be retained.

### Xml.RemoveChildByIndex

`Chilkat 11.7.0 · c · Xml · RemoveChildByIndex · method`

```c
void CkXml_RemoveChildByIndex(HCkXml cHandle, int index);
```

Removes the direct child at zero-based `index`, including that child's entire subtree.

### Xml.RemoveChildWithContent

`Chilkat 11.7.0 · c · Xml · RemoveChildWithContent · method`

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

Removes all direct children whose text content exactly equals `content`, including each removed child's subtree.

### Xml.RemoveFromTree

`Chilkat 11.7.0 · c · Xml · RemoveFromTree · method`

```c
void CkXml_RemoveFromTree(HCkXml cHandle);
```

Detaches the calling element and its entire subtree from its parent. The detached element becomes the root of its own independent XML tree.

**Object remains usable:** This method removes the subtree from its former document but keeps the calling `Xml` object referencing the detached subtree.

### Xml.RemoveStyleSheet

`Chilkat 11.7.0 · c · Xml · RemoveStyleSheet · method · since 9.5.0.77`

```c
int CkXml_RemoveStyleSheet(HCkXml cHandle, const char *attrName, const char *attrValue);
```

Removes XML stylesheet processing instructions whose attribute named `attrName` has the value `attrValue`.

Returns the number of matching stylesheet declarations removed, or `-1` if an error occurs.

### Xml.SaveBinaryContent

`Chilkat 11.7.0 · c · Xml · SaveBinaryContent · method`

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

Decodes the binary content stored in this element and writes the resulting bytes to `filename`. Set `unzipFlag` and `decryptFlag` to reverse the transformations originally applied, and supply the corresponding `password` when decrypting.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.SaveXml

`Chilkat 11.7.0 · c · Xml · SaveXml · method`

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

Serializes the XML tree or subtree rooted at the current element and writes it to `fileName`.

Document/output properties such as `Encoding`, `EmitBom`, `EmitXmlDecl`, and `EmitCompact` affect the generated output as applicable.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.Scrub

`Chilkat 11.7.0 · c · Xml · Scrub · method · since 9.5.0.77`

```c
void CkXml_Scrub(HCkXml cHandle, const char *directives);
```

Recursively normalizes the XML subtree rooted at the calling element according to the comma-separated keywords in `directives`.

Supported directives are:

- `AttrTrimEnds` - remove leading and trailing whitespace from attribute values.
- `AttrTrimInside` - replace tabs, CR, and LF with spaces and collapse repeated spaces inside attribute values.
- `ContentTrimEnds` - remove leading and trailing whitespace from element content.
- `ContentTrimInside` - normalize internal tabs/line breaks/spaces in element content.
- `LowercaseAttrs` - convert attribute names to lowercase.
- `LowercaseTags` - convert tag names to lowercase.
- `RemoveCtrl` - remove US-ASCII control characters with values 0-31 except TAB, CR, and LF.

**Destructive normalization:** Scrubbing modifies the tree. Use these options only when the corresponding whitespace, letter case, or control characters are not semantically significant to the application.

### Xml.SearchAllForContent

`Chilkat 11.7.0 · c · Xml · SearchAllForContent · method`

```c
HCkXml CkXml_SearchAllForContent(HCkXml cHandle, HCkXml afterPtr, const char *contentPattern);
```

Returns the first element whose text content matches `contentPattern`, regardless of tag name.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Iteration:** Pass the element returned by one call as `afterPtr` on the next call to continue to the next match. Continue until no further element is returned.

Returns `NULL` on failure

### Xml.SearchAllForContent2

`Chilkat 11.7.0 · c · Xml · SearchAllForContent2 · method`

```c
BOOL CkXml_SearchAllForContent2(HCkXml cHandle, HCkXml afterPtr, const char *contentPattern);
```

Performs the same breadth-first content search as `SearchAllForContent`, but moves the calling `Xml` object's internal reference to the matching element instead of returning a separate element object.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.SearchForAttribute

`Chilkat 11.7.0 · c · Xml · SearchForAttribute · method`

```c
HCkXml CkXml_SearchForAttribute(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *attr, const char *valuePattern);
```

Returns the first element whose tag equals `tag`, that has an attribute named `attr`, and whose attribute value matches `valuePattern`.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Iteration:** Pass the previous match as `afterPtr` to continue searching after that element.

Returns `NULL` on failure

### Xml.SearchForAttribute2

`Chilkat 11.7.0 · c · Xml · SearchForAttribute2 · method`

```c
BOOL CkXml_SearchForAttribute2(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *attr, const char *valuePattern);
```

Performs the same breadth-first tag/attribute search as `SearchForAttribute`, but moves the calling `Xml` object's internal reference to the matching element instead of returning a separate object.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.SearchForContent

`Chilkat 11.7.0 · c · Xml · SearchForContent · method`

```c
HCkXml CkXml_SearchForContent(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *contentPattern);
```

Returns the first element whose tag equals `tag` and whose text content matches `contentPattern`.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Iteration:** Pass the previous match as `afterPtr` to continue searching after that element.

Returns `NULL` on failure

### Xml.SearchForContent2

`Chilkat 11.7.0 · c · Xml · SearchForContent2 · method`

```c
BOOL CkXml_SearchForContent2(HCkXml cHandle, HCkXml afterPtr, const char *tag, const char *contentPattern);
```

Performs the same breadth-first tag/content search as `SearchForContent`, but moves the calling `Xml` object's internal reference to the matching element.

The search is breadth-first within the subtree rooted at the caller. The `afterPtr` argument identifies the element after which matching should begin, allowing repeated calls to continue an iteration. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element instead.

Wildcard patterns are case-sensitive and may contain `*`, where each asterisk matches zero or more characters.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.SearchForTag

`Chilkat 11.7.0 · c · Xml · SearchForTag · method`

```c
HCkXml CkXml_SearchForTag(HCkXml cHandle, HCkXml afterPtr, const char *tag);
```

Returns the first element whose tag exactly equals `tag`.

The search is breadth-first within the subtree rooted at the caller. `afterPtr` identifies the element after which searching begins. To begin at the first candidate, use `NULL` where the language binding permits it; ActiveX callers should pass a reference to the caller's element.

**Iteration:** Pass the previous match as `afterPtr` to find the next matching tag. Continue until no further element is returned.

Returns `NULL` on failure

### Xml.SearchForTag2

`Chilkat 11.7.0 · c · Xml · SearchForTag2 · method`

```c
BOOL CkXml_SearchForTag2(HCkXml cHandle, HCkXml afterPtr, const char *tag);
```

Performs the same breadth-first tag search as `SearchForTag`, but moves the calling `Xml` object's internal reference to the matching element instead of returning a separate object.

Use `afterPtr` in the same way as with `SearchForTag` to begin or continue the search.

**Element-reference behavior:** Methods that return an `Xml` object return another object referencing an element in the same underlying tree. Methods whose names end in `2` instead move the caller's internal reference.

Returns TRUE for success, FALSE for failure.

### Xml.SetBinaryContentBd

`Chilkat 11.7.0 · c · Xml · SetBinaryContentBd · method · since 11.0.0`

```c
BOOL CkXml_SetBinaryContentBd(HCkXml cHandle, HCkBinData data, BOOL zipFlag, BOOL encryptFlag, const char *password);
```

Stores the bytes in `data` as binary content on this element, with optional ZIP compression and optional password-based AES encryption. The stored binary representation is emitted as Base64 text when XML is serialized.

If `zipFlag` is `TRUE`, the bytes are compressed first. If `encryptFlag` is `TRUE`, the data is encrypted using Chilkat's 128-bit Rijndael/AES format and `password`.

Returns `TRUE` on success and `FALSE` on failure.

**Round trip:** Use the corresponding binary-content retrieval methods with matching decompression/decryption options to recover the original bytes.

Returns TRUE for success, FALSE for failure.

### Xml.SetBinaryContentFromFile

`Chilkat 11.7.0 · c · Xml · SetBinaryContentFromFile · method`

```c
BOOL CkXml_SetBinaryContentFromFile(HCkXml cHandle, const char *filename, BOOL zipFlag, BOOL encryptFlag, const char *password);
```

Reads the bytes from `filename` and stores them as this element's binary content, with optional ZIP compression and optional password-based encryption. The resulting stored data is represented as Base64 when XML text is generated.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.SortByAttribute

`Chilkat 11.7.0 · c · Xml · SortByAttribute · method`

```c
void CkXml_SortByAttribute(HCkXml cHandle, const char *attrName, BOOL ascending);
```

Sorts the calling element's direct children by the string value of attribute `attrName`. Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order.

`SortCaseInsensitive` controls case sensitivity for string sorting.

### Xml.SortByAttributeInt

`Chilkat 11.7.0 · c · Xml · SortByAttributeInt · method`

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

Sorts the calling element's direct children numerically by the value of attribute `attrName`, interpreting each sort value as an integer rather than comparing the text lexicographically.

Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order.

### Xml.SortByContent

`Chilkat 11.7.0 · c · Xml · SortByContent · method`

```c
void CkXml_SortByContent(HCkXml cHandle, BOOL ascending);
```

Sorts the calling element's direct children by their text content. Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order.

`SortCaseInsensitive` controls case sensitivity for the string comparison.

### Xml.SortByTag

`Chilkat 11.7.0 · c · Xml · SortByTag · method`

```c
void CkXml_SortByTag(HCkXml cHandle, BOOL ascending);
```

Sorts the calling element's direct children by tag name. Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order.

`SortCaseInsensitive` controls case sensitivity for the tag-name comparison.

### Xml.SortRecordsByAttribute

`Chilkat 11.7.0 · c · Xml · SortRecordsByAttribute · method`

```c
void CkXml_SortRecordsByAttribute(HCkXml cHandle, const char *sortTag, const char *attrName, BOOL ascending);
```

Treats each direct child as a record and sorts those records by the value of attribute `attrName` on the record's child identified by `sortTag`.

Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order. String comparisons honor `SortCaseInsensitive`.

### Xml.SortRecordsByContent

`Chilkat 11.7.0 · c · Xml · SortRecordsByContent · method`

```c
void CkXml_SortRecordsByContent(HCkXml cHandle, const char *sortTag, BOOL ascending);
```

Treats each direct child as a record and sorts those records by the text content of the record's child named `sortTag`.

Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order. String comparisons honor `SortCaseInsensitive`.

### Xml.SortRecordsByContentInt

`Chilkat 11.7.0 · c · Xml · SortRecordsByContentInt · method`

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

Treats each direct child as a record and sorts those records numerically by the integer content of the record's child named `sortTag`.

Numeric comparison is used instead of lexicographic string comparison. Set `ascending` to `TRUE` for ascending order or `FALSE` for descending order.

### Xml.SwapNode

`Chilkat 11.7.0 · c · Xml · SwapNode · method`

```c
BOOL CkXml_SwapNode(HCkXml cHandle, HCkXml node);
```

Swaps the calling element's tag, text content, and attributes with those of `node`.

Returns `TRUE` on success and `FALSE` on failure.

**Children are not swapped:** Use `SwapTree` when child subtrees should also be exchanged.

Returns TRUE for success, FALSE for failure.

### Xml.SwapTree

`Chilkat 11.7.0 · c · Xml · SwapTree · method`

```c
BOOL CkXml_SwapTree(HCkXml cHandle, HCkXml tree);
```

Swaps the calling element's complete tree state with `tree`, including tag, text content, attributes, and children.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.TagContent

`Chilkat 11.7.0 · c · Xml · TagContent · method`

```c
BOOL CkXml_TagContent(HCkXml cHandle, const char *tagName, HCkString outStr);
const char *CkXml_tagContent(HCkXml cHandle, const char *tagName);
```

Searches the subtree rooted at the calling element for the first element whose tag equals `tagName` and returns that element's text content.

**Recursive search:** Unlike direct-child getters, this search is not limited to the caller's immediate children.

Returns TRUE for success, FALSE for failure.

### Xml.TagEquals

`Chilkat 11.7.0 · c · Xml · TagEquals · method`

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

Returns `TRUE` if the calling element's complete tag name, including any namespace prefix, exactly equals `tag`; otherwise returns `FALSE`.

### Xml.TagIndex

`Chilkat 11.7.0 · c · Xml · TagIndex · method · since 9.5.0.76`

```c
int CkXml_TagIndex(HCkXml cHandle, const char *tagPath);
```

Returns the zero-based child index of the element selected by `tagPath`. Returns `-1` when no matching element is found at that path.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

**Index meaning:** The returned index is the element's position among its parent's direct children, which is the index accepted by methods such as `GetChild`, `RemoveChildByIndex`, and the insertion methods.

### Xml.TagNsEquals

`Chilkat 11.7.0 · c · Xml · TagNsEquals · method · since 9.5.0.77`

```c
BOOL CkXml_TagNsEquals(HCkXml cHandle, const char *ns);
```

Returns `TRUE` if this element's namespace-prefix portion exactly equals `ns`; otherwise returns `FALSE`.

For example, the namespace prefix of `soapenv:Body` is `soapenv`.

**Prefix comparison:** This compares the lexical prefix, not the namespace URI bound to that prefix.

### Xml.TagUnpEquals

`Chilkat 11.7.0 · c · Xml · TagUnpEquals · method · since 9.5.0.77`

```c
BOOL CkXml_TagUnpEquals(HCkXml cHandle, const char *unprefixedTag);
```

Returns `TRUE` if this element's unprefixed tag exactly equals `unprefixedTag`; otherwise returns `FALSE`.

For example, the unprefixed tag of `soapenv:Body` is `Body`.

### Xml.UnzipContent

`Chilkat 11.7.0 · c · Xml · UnzipContent · method`

```c
BOOL CkXml_UnzipContent(HCkXml cHandle);
```

Reverses `ZipContent`: decodes and decompresses the calling element's compressed content and replaces the stored Base64-compressed representation with the original content.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.UnzipTree

`Chilkat 11.7.0 · c · Xml · UnzipTree · method`

```c
BOOL CkXml_UnzipTree(HCkXml cHandle);
```

Reverses `ZipTree`: decompresses the stored representation and reconstructs the calling element's previously compressed subtree.

The element's tag and attributes, which are not replaced by `ZipTree`, remain associated with the restored tree.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.UpdateAt

`Chilkat 11.7.0 · c · Xml · UpdateAt · method · since 9.5.0.64`

```c
BOOL CkXml_UpdateAt(HCkXml cHandle, const char *tagPath, BOOL autoCreate, const char *value);
```

Sets the text content of the element selected by `tagPath` to `value`.

If `autoCreate` is `TRUE`, missing elements along the path are created as needed. If it is `FALSE`, the update requires the target path to already exist.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns TRUE for success, FALSE for failure.

### Xml.UpdateAttrAt

`Chilkat 11.7.0 · c · Xml · UpdateAttrAt · method · since 9.5.0.64`

```c
BOOL CkXml_UpdateAttrAt(HCkXml cHandle, const char *tagPath, BOOL autoCreate, const char *attrName, const char *attrValue);
```

Sets attribute `attrName` to `attrValue` on the element selected by `tagPath`. The attribute is added when it does not already exist.

If `autoCreate` is `TRUE`, missing elements along the path are created as needed. If it is `FALSE`, the target path must already exist.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

Returns TRUE for success, FALSE for failure.

### Xml.UpdateAttribute

`Chilkat 11.7.0 · c · Xml · UpdateAttribute · method`

```c
BOOL CkXml_UpdateAttribute(HCkXml cHandle, const char *attrName, const char *attrValue);
```

Sets attribute `attrName` to `attrValue`. If the attribute already exists its value is replaced; otherwise the attribute is added.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.UpdateAttributeInt

`Chilkat 11.7.0 · c · Xml · UpdateAttributeInt · method`

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

Sets attribute `attrName` to the decimal representation of integer `value`. Use `UpdateAttribute` for string values.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

### Xml.UpdateChildContent

`Chilkat 11.7.0 · c · Xml · UpdateChildContent · method`

```c
void CkXml_UpdateChildContent(HCkXml cHandle, const char *tagPath, const char *value);
```

Sets the text content of the child selected by `tagPath` to `value`. Missing elements along the path are automatically created as needed.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.UpdateChildContentInt

`Chilkat 11.7.0 · c · Xml · UpdateChildContentInt · method`

```c
void CkXml_UpdateChildContentInt(HCkXml cHandle, const char *tagPath, int value);
```

Sets the content of the child selected by `tagPath` to the decimal representation of integer `value`.

**Tag paths:** A tag path is Chilkat's `|`-separated child-navigation syntax, for example `tagA|tagB|tagC`. It is not XPath.

### Xml.ZipContent

`Chilkat 11.7.0 · c · Xml · ZipContent · method`

```c
BOOL CkXml_ZipContent(HCkXml cHandle);
```

ZIP-compresses this element's text content and replaces the original content with Base64-encoded compressed data.

Returns `TRUE` on success and `FALSE` on failure.

**Reversible transformation:** Call `UnzipContent` to restore the original content.

Returns TRUE for success, FALSE for failure.

### Xml.ZipTree

`Chilkat 11.7.0 · c · Xml · ZipTree · method`

```c
BOOL CkXml_ZipTree(HCkXml cHandle);
```

ZIP-compresses the calling element's content together with its entire child subtree and replaces that structure with Base64-encoded compressed data.

The calling element's tag and attributes are not changed. Call `UnzipTree` to reconstruct the compressed subtree.

Returns `TRUE` on success and `FALSE` on failure.

Returns TRUE for success, FALSE for failure.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `BEncodeContent` | method | before 11.6.1 | — |
| `DecodeContent` | method | before 11.6.1 | — |
| `GetBinaryContent` | method | before 11.6.1 | — |
| `QEncodeContent` | method | before 11.6.1 | — |
| `SetBinaryContent` | method | before 11.6.1 | — |

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/BinData.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/c/classes/StringBuilder.md)

