---
product: Chilkat
product_version: 11.7.0
language: pascal
language_label: Lazarus Pascal
class: Xml
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/pascal_XmlRef.html
---
# Chilkat Xml — Lazarus Pascal — v11.7.0

> Chilkat 11.7.0 · language=pascal · 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/pascal/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 / Free**

```pascal
uses
  Chilkat.Xml;

var
  obj: TXml;
begin
  obj := TXml.Create;
  try
    if not obj.IsValid then
      raise Exception.Create('Failed to create a TXml instance.');

    // ... use obj ...

  finally
    obj.Free;
  end;
end;
```

`constructor Create;`

Allocates the underlying CkXml object and returns a new TXml instance. Simply adding **Chilkat.Xml** to the unit's `uses` clause is enough to locate and bind to the Chilkat shared library (DLL / .so / .dylib) at runtime — no separate load step is required. Check `obj.IsValid` after calling `Create`; it is `False` if the underlying library could not be found/loaded or the object could not be allocated (for example, when unlicensed).

`destructor Destroy; override;`

Every TXml created by calling `Create` should eventually be released by calling `.Free` (inherited from `TObject`). The destructor automatically disposes the underlying CkXml handle. A native (unmanaged) memory leak occurs if the object is never freed.

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

## 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` | `property DebugLogFilePath: string read GetDebugLogFilePath write SetDebugLogFilePath;` | 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` | `property LastErrorHtml: string read GetLastErrorHtml;` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `property LastErrorText: string read GetLastErrorText;` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `property LastErrorXml: string read GetLastErrorXml;` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `property LastMethodSuccess: Boolean read GetLastMethodSuccess write SetLastMethodSuccess;` | read/write | Indicates the success or failure of the most recent method call: `True` means success, `False` means failure. |
| `VerboseLogging` | `property VerboseLogging: Boolean read GetVerboseLogging write SetVerboseLogging;` | read/write | If set to `True`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `property Version: string read GetVersion;` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `Cdata` | property, read/write | `property Cdata: Boolean read GetCdata write SetCdata;` |
| `Content` | property, read/write | `property Content: string read GetContent write SetContent;` |
| `ContentInt` | property, read/write | `property ContentInt: Integer read GetContentInt write SetContentInt;` |
| `DocType` | property, read/write | `property DocType: string read GetDocType write SetDocType;` |
| `EmitBom` | property, read/write | `property EmitBom: Boolean read GetEmitBom write SetEmitBom;` |
| `EmitCompact` | property, read/write | `property EmitCompact: Boolean read GetEmitCompact write SetEmitCompact;` |
| `EmitXmlDecl` | property, read/write | `property EmitXmlDecl: Boolean read GetEmitXmlDecl write SetEmitXmlDecl;` |
| `Encoding` | property, read/write | `property Encoding: string read GetEncoding write SetEncoding;` |
| `I` | property, read/write | `property I: Integer read GetI write SetI;` |
| `IsBase64` | property, read-only | `property IsBase64: Boolean read GetIsBase64;` |
| `J` | property, read/write | `property J: Integer read GetJ write SetJ;` |
| `K` | property, read/write | `property K: Integer read GetK write SetK;` |
| `NumAttributes` | property, read-only | `property NumAttributes: Integer read GetNumAttributes;` |
| `NumChildren` | property, read-only | `property NumChildren: Integer read GetNumChildren;` |
| `SortCaseInsensitive` | property, read/write | `property SortCaseInsensitive: Boolean read GetSortCaseInsensitive write SetSortCaseInsensitive;` |
| `Standalone` | property, read/write | `property Standalone: Boolean read GetStandalone write SetStandalone;` |
| `Strict` | property, read/write | `property Strict: Boolean read GetStrict write SetStrict;` |
| `Tag` | property, read/write | `property Tag: string read GetTag write SetTag;` |
| `TagNsPrefix` | property, read/write | `property TagNsPrefix: string read GetTagNsPrefix write SetTagNsPrefix;` |
| `TagPath` | property, read-only | `property TagPath: string read GetTagPath;` |
| `TagUnprefixed` | property, read/write | `property TagUnprefixed: string read GetTagUnprefixed write SetTagUnprefixed;` |
| `TreeId` | property, read-only | `property TreeId: Integer read GetTreeId;` |
| `UncommonOptions` | property, read/write | `property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;` |
| `AccumulateTagContent` | method | `function AccumulateTagContent(const tag: string;     const skipTags: string): string;` |
| `AddAttribute` | method | `function AddAttribute(const name: string;     const value: string): Boolean;` |
| `AddAttributeInt` | method | `function AddAttributeInt(const name: string;     value: Integer): Boolean;` |
| `AddChildTree` | method | `// tree is a TXml object. function AddChildTree(tree: TChilkatBase): Boolean;` |
| `AddOrUpdateAttribute` | method | `procedure AddOrUpdateAttribute(const name: string;     const value: string);` |
| `AddOrUpdateAttributeI` | method | `procedure AddOrUpdateAttributeI(const name: string;     value: Integer);` |
| `AddStyleSheet` | method | `procedure AddStyleSheet(const styleSheet: string);` |
| `AddToAttribute` | method | `procedure AddToAttribute(const name: string;     amount: Integer);` |
| `AddToChildContent` | method | `procedure AddToChildContent(const tag: string;     amount: Integer);` |
| `AddToContent` | method | `procedure AddToContent(amount: Integer);` |
| `AppendToContent` | method | `function AppendToContent(const str: string): Boolean;` |
| `ChildContentMatches` | method | `function ChildContentMatches(const tagPath: string;     const pattern: string;     caseSensitive: Boolean): Boolean;` |
| `ChilkatPath` | method | `function ChilkatPath(const pathCmd: string): string;` |
| `Clear` | method | `procedure Clear;` |
| `ContentMatches` | method | `function ContentMatches(const pattern: string;     caseSensitive: Boolean): Boolean;` |
| `Copy` | method | `// node is a TXml object. procedure Copy(node: TChilkatBase);` |
| `CopyRef` | method | `// copyFromNode is a TXml object. procedure CopyRef(copyFromNode: TChilkatBase);` |
| `DecodeEntities` | method | `function DecodeEntities(const str: string): string;` |
| `DecryptContent` | method | `function DecryptContent(const password: string): Boolean;` |
| `EncryptContent` | method | `function EncryptContent(const password: string): Boolean;` |
| `ExtractChildByIndex` | method | `// Return value is a TXml object. function ExtractChildByIndex(index: Integer): TChilkatBase;` |
| `ExtractChildByName` | method | `// Return value is a TXml object. function ExtractChildByName(const tagPath: string;     const attrName: string;     const attrValue: string): TChilkatBase;` |
| `FindChild` | method | `// Return value is a TXml object. function FindChild(const tagPath: string): TChilkatBase;` |
| `FindChild2` | method | `function FindChild2(const tagPath: string): Boolean;` |
| `FindNextRecord` | method | `// Return value is a TXml object. function FindNextRecord(const tagPath: string;     const contentPattern: string): TChilkatBase;` |
| `FindOrAddNewChild` | method | `// Return value is a TXml object. function FindOrAddNewChild(const tagPath: string): TChilkatBase;` |
| `FirstChild` | method | `// Return value is a TXml object. function FirstChild: TChilkatBase;` |
| `FirstChild2` | method | `function FirstChild2: Boolean;` |
| `GetAttributeName` | method | `function GetAttributeName(index: Integer): string;` |
| `GetAttributeValue` | method | `function GetAttributeValue(index: Integer): string;` |
| `GetAttributeValueInt` | method | `function GetAttributeValueInt(index: Integer): Integer;` |
| `GetAttrValue` | method | `function GetAttrValue(const name: string): string;` |
| `GetAttrValueInt` | method | `function GetAttrValueInt(const name: string): Integer;` |
| `GetChild` | method | `// Return value is a TXml object. function GetChild(index: Integer): TChilkatBase;` |
| `GetChild2` | method | `function GetChild2(index: Integer): Boolean;` |
| `GetChildAttrValue` | method | `function GetChildAttrValue(const tagPath: string;     const attrName: string): string;` |
| `GetChildBoolValue` | method | `function GetChildBoolValue(const tagPath: string): Boolean;` |
| `GetChildContent` | method | `function GetChildContent(const tagPath: string): string;` |
| `GetChildContentByIndex` | method | `function GetChildContentByIndex(index: Integer): string;` |
| `GetChildContentSb` | method | `// sb is a TStringBuilder object. function GetChildContentSb(const tagPath: string;     sb: TChilkatBase): Boolean;` |
| `GetChildExact` | method | `// Return value is a TXml object. function GetChildExact(const tag: string;     const content: string): TChilkatBase;` |
| `GetChildIntValue` | method | `function GetChildIntValue(const tagPath: string): Integer;` |
| `GetChildTag` | method | `function GetChildTag(index: Integer): string;` |
| `GetChildTagByIndex` | method | `function GetChildTagByIndex(index: Integer): string;` |
| `GetChildWithAttr` | method | `// Return value is a TXml object. function GetChildWithAttr(const tagPath: string;     const attrName: string;     const attrValue: string): TChilkatBase;` |
| `GetChildWithContent` | method | `// Return value is a TXml object. function GetChildWithContent(const content: string): TChilkatBase;` |
| `GetChildWithTag` | method | `// Return value is a TXml object. function GetChildWithTag(const tagPath: string): TChilkatBase;` |
| `GetChildWithTag2` | method | `function GetChildWithTag2(const tagPath: string): Boolean;` |
| `GetNthChildWithTag` | method | `// Return value is a TXml object. function GetNthChildWithTag(const tag: string;     n: Integer): TChilkatBase;` |
| `GetNthChildWithTag2` | method | `function GetNthChildWithTag2(const tag: string;     n: Integer): Boolean;` |
| `GetParent` | method | `// Return value is a TXml object. function GetParent: TChilkatBase;` |
| `GetParent2` | method | `function GetParent2: Boolean;` |
| `GetRoot` | method | `// Return value is a TXml object. function GetRoot: TChilkatBase;` |
| `GetRoot2` | method | `procedure GetRoot2;` |
| `GetSelf` | method | `// Return value is a TXml object. function GetSelf: TChilkatBase;` |
| `GetXml` | method | `function GetXml: string;` |
| `GetXmlBd` | method | `// bd is a TBinData object. function GetXmlBd(bd: TChilkatBase): Boolean;` |
| `GetXmlSb` | method | `// sb is a TStringBuilder object. function GetXmlSb(sb: TChilkatBase): Boolean;` |
| `HasAttribute` | method | `function HasAttribute(const name: string): Boolean;` |
| `HasAttrWithValue` | method | `function HasAttrWithValue(const name: string;     const value: string): Boolean;` |
| `HasChildWithContent` | method | `function HasChildWithContent(const content: string): Boolean;` |
| `HasChildWithTag` | method | `function HasChildWithTag(const tagPath: string): Boolean;` |
| `HasChildWithTagAndContent` | method | `function HasChildWithTagAndContent(const tagPath: string;     const content: string): Boolean;` |
| `InsertChildTreeAfter` | method | `// tree is a TXml object. procedure InsertChildTreeAfter(index: Integer;     tree: TChilkatBase);` |
| `InsertChildTreeBefore` | method | `// tree is a TXml object. procedure InsertChildTreeBefore(index: Integer;     tree: TChilkatBase);` |
| `LastChild` | method | `// Return value is a TXml object. function LastChild: TChilkatBase;` |
| `LastChild2` | method | `function LastChild2: Boolean;` |
| `LoadBd` | method | `// bd is a TBinData object. function LoadBd(bd: TChilkatBase;     autoTrim: Boolean): Boolean;` |
| `LoadSb` | method | `// sb is a TStringBuilder object. function LoadSb(sb: TChilkatBase;     autoTrim: Boolean): Boolean;` |
| `LoadXml` | method | `function LoadXml(const xmlData: string): Boolean;` |
| `LoadXml2` | method | `function LoadXml2(const xmlData: string;     autoTrim: Boolean): Boolean;` |
| `LoadXmlFile` | method | `function LoadXmlFile(const fileName: string): Boolean;` |
| `LoadXmlFile2` | method | `function LoadXmlFile2(const fileName: string;     autoTrim: Boolean): Boolean;` |
| `NewChild` | method | `// Return value is a TXml object. function NewChild(const tagPath: string;     const content: string): TChilkatBase;` |
| `NewChild2` | method | `procedure NewChild2(const tagPath: string;     const content: string);` |
| `NewChildAfter` | method | `// Return value is a TXml object. function NewChildAfter(index: Integer;     const tag: string;     const content: string): TChilkatBase;` |
| `NewChildBefore` | method | `// Return value is a TXml object. function NewChildBefore(index: Integer;     const tag: string;     const content: string): TChilkatBase;` |
| `NewChildInt2` | method | `procedure NewChildInt2(const tagPath: string;     value: Integer);` |
| `NextInTraversal2` | method | `// sbState is a TStringBuilder object. function NextInTraversal2(sbState: TChilkatBase): Boolean;` |
| `NextSibling` | method | `// Return value is a TXml object. function NextSibling: TChilkatBase;` |
| `NextSibling2` | method | `function NextSibling2: Boolean;` |
| `NumChildrenAt` | method | `function NumChildrenAt(const tagPath: string): Integer;` |
| `NumChildrenHavingTag` | method | `function NumChildrenHavingTag(const tag: string): Integer;` |
| `PreviousSibling` | method | `// Return value is a TXml object. function PreviousSibling: TChilkatBase;` |
| `PreviousSibling2` | method | `function PreviousSibling2: Boolean;` |
| `PruneAttribute` | method | `function PruneAttribute(const attrName: string): Integer;` |
| `PruneTag` | method | `function PruneTag(const tag: string): Integer;` |
| `RemoveAllAttributes` | method | `function RemoveAllAttributes: Boolean;` |
| `RemoveAllChildren` | method | `procedure RemoveAllChildren;` |
| `RemoveAttribute` | method | `function RemoveAttribute(const name: string): Boolean;` |
| `RemoveChild` | method | `procedure RemoveChild(const tagPath: string);` |
| `RemoveChildByIndex` | method | `procedure RemoveChildByIndex(index: Integer);` |
| `RemoveChildWithContent` | method | `procedure RemoveChildWithContent(const content: string);` |
| `RemoveFromTree` | method | `procedure RemoveFromTree;` |
| `RemoveStyleSheet` | method | `function RemoveStyleSheet(const attrName: string;     const attrValue: string): Integer;` |
| `SaveBinaryContent` | method | `function SaveBinaryContent(const filename: string;     unzipFlag: Boolean;     decryptFlag: Boolean;     const password: string): Boolean;` |
| `SaveXml` | method | `function SaveXml(const fileName: string): Boolean;` |
| `Scrub` | method | `procedure Scrub(const directives: string);` |
| `SetBinaryContentBd` | method | `// data is a TBinData object. function SetBinaryContentBd(data: TChilkatBase;     zipFlag: Boolean;     encryptFlag: Boolean;     const password: string): Boolean;` |
| `SetBinaryContentFromFile` | method | `function SetBinaryContentFromFile(const filename: string;     zipFlag: Boolean;     encryptFlag: Boolean;     const password: string): Boolean;` |
| `SortByAttribute` | method | `procedure SortByAttribute(const attrName: string;     ascending: Boolean);` |
| `SortByAttributeInt` | method | `procedure SortByAttributeInt(const attrName: string;     ascending: Boolean);` |
| `SortByContent` | method | `procedure SortByContent(ascending: Boolean);` |
| `SortByTag` | method | `procedure SortByTag(ascending: Boolean);` |
| `SortRecordsByAttribute` | method | `procedure SortRecordsByAttribute(const sortTag: string;     const attrName: string;     ascending: Boolean);` |
| `SortRecordsByContent` | method | `procedure SortRecordsByContent(const sortTag: string;     ascending: Boolean);` |
| `SortRecordsByContentInt` | method | `procedure SortRecordsByContentInt(const sortTag: string;     ascending: Boolean);` |
| `SwapNode` | method | `// node is a TXml object. function SwapNode(node: TChilkatBase): Boolean;` |
| `SwapTree` | method | `// tree is a TXml object. function SwapTree(tree: TChilkatBase): Boolean;` |
| `TagContent` | method | `function TagContent(const tagName: string): string;` |
| `TagEquals` | method | `function TagEquals(const tag: string): Boolean;` |
| `TagIndex` | method | `function TagIndex(const tagPath: string): Integer;` |
| `TagNsEquals` | method | `function TagNsEquals(const ns: string): Boolean;` |
| `TagUnpEquals` | method | `function TagUnpEquals(const unprefixedTag: string): Boolean;` |
| `UnzipContent` | method | `function UnzipContent: Boolean;` |
| `UnzipTree` | method | `function UnzipTree: Boolean;` |
| `UpdateAt` | method | `function UpdateAt(const tagPath: string;     autoCreate: Boolean;     const value: string): Boolean;` |
| `UpdateAttrAt` | method | `function UpdateAttrAt(const tagPath: string;     autoCreate: Boolean;     const attrName: string;     const attrValue: string): Boolean;` |
| `UpdateAttribute` | method | `function UpdateAttribute(const attrName: string;     const attrValue: string): Boolean;` |
| `UpdateAttributeInt` | method | `function UpdateAttributeInt(const attrName: string;     value: Integer): Boolean;` |
| `UpdateChildContent` | method | `procedure UpdateChildContent(const tagPath: string;     const value: string);` |
| `UpdateChildContentInt` | method | `procedure UpdateChildContentInt(const tagPath: string;     value: Integer);` |
| `ZipContent` | method | `function ZipContent: Boolean;` |
| `ZipTree` | method | `function ZipTree: Boolean;` |

## Properties

### Xml.Cdata

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

```pascal
property Cdata: Boolean read GetCdata write SetCdata;
```

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 · pascal · Xml · Content · property · read/write`

```pascal
property Content: string read GetContent write SetContent;
```

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 · pascal · Xml · ContentInt · property · read/write`

```pascal
property ContentInt: Integer read GetContentInt write SetContentInt;
```

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 · pascal · Xml · DocType · property · read/write`

```pascal
property DocType: string read GetDocType write SetDocType;
```

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 · pascal · Xml · EmitBom · property · read/write · since 9.5.0.44`

```pascal
property EmitBom: Boolean read GetEmitBom write SetEmitBom;
```

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 · pascal · Xml · EmitCompact · property · read/write · since 9.5.0.64`

```pascal
property EmitCompact: Boolean read GetEmitCompact write SetEmitCompact;
```

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 · pascal · Xml · EmitXmlDecl · property · read/write`

```pascal
property EmitXmlDecl: Boolean read GetEmitXmlDecl write SetEmitXmlDecl;
```

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 · pascal · Xml · Encoding · property · read/write`

```pascal
property Encoding: string read GetEncoding write SetEncoding;
```

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 · pascal · Xml · I · property · read/write · since 9.5.0.64`

```pascal
property I: Integer read GetI write SetI;
```

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 · pascal · Xml · IsBase64 · property · read-only · since 9.5.0.76`

```pascal
property IsBase64: Boolean read GetIsBase64;
```

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 · pascal · Xml · J · property · read/write · since 9.5.0.64`

```pascal
property J: Integer read GetJ write SetJ;
```

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 · pascal · Xml · K · property · read/write · since 9.5.0.64`

```pascal
property K: Integer read GetK write SetK;
```

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 · pascal · Xml · NumAttributes · property · read-only`

```pascal
property NumAttributes: Integer read GetNumAttributes;
```

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 · pascal · Xml · NumChildren · property · read-only`

```pascal
property NumChildren: Integer read GetNumChildren;
```

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 · pascal · Xml · SortCaseInsensitive · property · read/write`

```pascal
property SortCaseInsensitive: Boolean read GetSortCaseInsensitive write SetSortCaseInsensitive;
```

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 · pascal · Xml · Standalone · property · read/write`

```pascal
property Standalone: Boolean read GetStandalone write SetStandalone;
```

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 · pascal · Xml · Strict · property · read/write · since 11.6.0`

```pascal
property Strict: Boolean read GetStrict write SetStrict;
```

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 · pascal · Xml · Tag · property · read/write`

```pascal
property Tag: string read GetTag write SetTag;
```

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 · pascal · Xml · TagNsPrefix · property · read/write · since 9.5.0.77`

```pascal
property TagNsPrefix: string read GetTagNsPrefix write SetTagNsPrefix;
```

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 · pascal · Xml · TagPath · property · read-only · since 9.5.0.77`

```pascal
property TagPath: string read GetTagPath;
```

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 · pascal · Xml · TagUnprefixed · property · read/write · since 9.5.0.77`

```pascal
property TagUnprefixed: string read GetTagUnprefixed write SetTagUnprefixed;
```

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 · pascal · Xml · TreeId · property · read-only`

```pascal
property TreeId: Integer read GetTreeId;
```

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 · pascal · Xml · UncommonOptions · property · read/write · since 9.5.0.90`

```pascal
property UncommonOptions: string read GetUncommonOptions write SetUncommonOptions;
```

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 · pascal · Xml · AccumulateTagContent · method`

```pascal
function  AccumulateTagContent(const tag: string;
    const skipTags: string): string;
```

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 · pascal · Xml · AddAttribute · method`

```pascal
function  AddAttribute(const name: string;
    const value: string): Boolean;
```

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 · pascal · Xml · AddAttributeInt · method`

```pascal
function  AddAttributeInt(const name: string;
    value: Integer): Boolean;
```

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 · pascal · Xml · AddChildTree · method`

```pascal
// tree is a TXml object.

function  AddChildTree(tree: TChilkatBase): Boolean;
```

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 · pascal · Xml · AddOrUpdateAttribute · method`

```pascal
procedure AddOrUpdateAttribute(const name: string;
    const value: string);
```

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 · pascal · Xml · AddOrUpdateAttributeI · method`

```pascal
procedure AddOrUpdateAttributeI(const name: string;
    value: Integer);
```

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 · pascal · Xml · AddStyleSheet · method`

```pascal
procedure AddStyleSheet(const styleSheet: string);
```

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 · pascal · Xml · AddToAttribute · method`

```pascal
procedure AddToAttribute(const name: string;
    amount: Integer);
```

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 · pascal · Xml · AddToChildContent · method`

```pascal
procedure AddToChildContent(const tag: string;
    amount: Integer);
```

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 · pascal · Xml · AddToContent · method`

```pascal
procedure AddToContent(amount: Integer);
```

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 · pascal · Xml · AppendToContent · method`

```pascal
function  AppendToContent(const str: string): Boolean;
```

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 · pascal · Xml · ChildContentMatches · method`

```pascal
function  ChildContentMatches(const tagPath: string;
    const pattern: string;
    caseSensitive: Boolean): Boolean;
```

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 · pascal · Xml · ChilkatPath · method`

```pascal
function  ChilkatPath(const pathCmd: string): string;
```

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 · pascal · Xml · Clear · method`

```pascal
procedure Clear;
```

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 · pascal · Xml · ContentMatches · method`

```pascal
function  ContentMatches(const pattern: string;
    caseSensitive: Boolean): Boolean;
```

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 · pascal · Xml · Copy · method`

```pascal
// node is a TXml object.

procedure Copy(node: TChilkatBase);
```

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 · pascal · Xml · CopyRef · method`

```pascal
// copyFromNode is a TXml object.

procedure CopyRef(copyFromNode: TChilkatBase);
```

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 · pascal · Xml · DecodeEntities · method`

```pascal
function  DecodeEntities(const str: string): string;
```

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 · pascal · Xml · DecryptContent · method`

```pascal
function  DecryptContent(const password: string): Boolean;
```

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 · pascal · Xml · EncryptContent · method`

```pascal
function  EncryptContent(const password: string): Boolean;
```

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 · pascal · Xml · ExtractChildByIndex · method`

```pascal
// Return value is a TXml object.

function  ExtractChildByIndex(index: Integer): TChilkatBase;
```

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 `nil` on failure

### Xml.ExtractChildByName

`Chilkat 11.7.0 · pascal · Xml · ExtractChildByName · method`

```pascal
// Return value is a TXml object.

function  ExtractChildByName(const tagPath: string;
    const attrName: string;
    const attrValue: string): TChilkatBase;
```

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 `nil` on failure

### Xml.FindChild

`Chilkat 11.7.0 · pascal · Xml · FindChild · method`

```pascal
// Return value is a TXml object.

function  FindChild(const tagPath: string): TChilkatBase;
```

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 `nil` on failure

### Xml.FindChild2

`Chilkat 11.7.0 · pascal · Xml · FindChild2 · method`

```pascal
function  FindChild2(const tagPath: string): Boolean;
```

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 · pascal · Xml · FindNextRecord · method`

```pascal
// Return value is a TXml object.

function  FindNextRecord(const tagPath: string;
    const contentPattern: string): TChilkatBase;
```

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 `nil` on failure

### Xml.FindOrAddNewChild

`Chilkat 11.7.0 · pascal · Xml · FindOrAddNewChild · method`

```pascal
// Return value is a TXml object.

function  FindOrAddNewChild(const tagPath: string): TChilkatBase;
```

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 `nil` on failure

### Xml.FirstChild

`Chilkat 11.7.0 · pascal · Xml · FirstChild · method`

```pascal
// Return value is a TXml object.

function  FirstChild: TChilkatBase;
```

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 `nil` on failure

### Xml.FirstChild2

`Chilkat 11.7.0 · pascal · Xml · FirstChild2 · method`

```pascal
function  FirstChild2: Boolean;
```

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 · pascal · Xml · GetAttributeName · method`

```pascal
function  GetAttributeName(index: Integer): string;
```

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 · pascal · Xml · GetAttributeValue · method`

```pascal
function  GetAttributeValue(index: Integer): string;
```

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 · pascal · Xml · GetAttributeValueInt · method`

```pascal
function  GetAttributeValueInt(index: Integer): Integer;
```

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

### Xml.GetAttrValue

`Chilkat 11.7.0 · pascal · Xml · GetAttrValue · method`

```pascal
function  GetAttrValue(const name: string): string;
```

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 · pascal · Xml · GetAttrValueInt · method`

```pascal
function  GetAttrValueInt(const name: string): Integer;
```

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 · pascal · Xml · GetChild · method`

```pascal
// Return value is a TXml object.

function  GetChild(index: Integer): TChilkatBase;
```

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 `nil` on failure

### Xml.GetChild2

`Chilkat 11.7.0 · pascal · Xml · GetChild2 · method`

```pascal
function  GetChild2(index: Integer): Boolean;
```

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 · pascal · Xml · GetChildAttrValue · method · since 9.5.0.77`

```pascal
function  GetChildAttrValue(const tagPath: string;
    const attrName: string): string;
```

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 · pascal · Xml · GetChildBoolValue · method`

```pascal
function  GetChildBoolValue(const tagPath: string): Boolean;
```

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 · pascal · Xml · GetChildContent · method`

```pascal
function  GetChildContent(const tagPath: string): string;
```

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 · pascal · Xml · GetChildContentByIndex · method`

```pascal
function  GetChildContentByIndex(index: Integer): string;
```

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 · pascal · Xml · GetChildContentSb · method · since 9.5.0.76`

```pascal
// sb is a TStringBuilder object.

function  GetChildContentSb(const tagPath: string;
    sb: TChilkatBase): Boolean;
```

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 · pascal · Xml · GetChildExact · method`

```pascal
// Return value is a TXml object.

function  GetChildExact(const tag: string;
    const content: string): TChilkatBase;
```

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 `nil` on failure

### Xml.GetChildIntValue

`Chilkat 11.7.0 · pascal · Xml · GetChildIntValue · method`

```pascal
function  GetChildIntValue(const tagPath: string): Integer;
```

**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 · pascal · Xml · GetChildTag · method`

```pascal
function  GetChildTag(index: Integer): string;
```

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 · pascal · Xml · GetChildTagByIndex · method`

```pascal
function  GetChildTagByIndex(index: Integer): string;
```

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 · pascal · Xml · GetChildWithAttr · method`

```pascal
// Return value is a TXml object.

function  GetChildWithAttr(const tagPath: string;
    const attrName: string;
    const attrValue: string): TChilkatBase;
```

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 `nil` on failure

### Xml.GetChildWithContent

`Chilkat 11.7.0 · pascal · Xml · GetChildWithContent · method`

```pascal
// Return value is a TXml object.

function  GetChildWithContent(const content: string): TChilkatBase;
```

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

Returns `nil` on failure

### Xml.GetChildWithTag

`Chilkat 11.7.0 · pascal · Xml · GetChildWithTag · method`

```pascal
// Return value is a TXml object.

function  GetChildWithTag(const tagPath: string): TChilkatBase;
```

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 `nil` on failure

### Xml.GetChildWithTag2

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

```pascal
function  GetChildWithTag2(const tagPath: string): Boolean;
```

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 · pascal · Xml · GetNthChildWithTag · method`

```pascal
// Return value is a TXml object.

function  GetNthChildWithTag(const tag: string;
    n: Integer): TChilkatBase;
```

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 `nil` on failure

### Xml.GetNthChildWithTag2

`Chilkat 11.7.0 · pascal · Xml · GetNthChildWithTag2 · method`

```pascal
function  GetNthChildWithTag2(const tag: string;
    n: Integer): Boolean;
```

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 · pascal · Xml · GetParent · method`

```pascal
// Return value is a TXml object.

function  GetParent: TChilkatBase;
```

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 `nil` on failure

### Xml.GetParent2

`Chilkat 11.7.0 · pascal · Xml · GetParent2 · method`

```pascal
function  GetParent2: Boolean;
```

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 · pascal · Xml · GetRoot · method`

```pascal
// Return value is a TXml object.

function  GetRoot: TChilkatBase;
```

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 `nil` on failure

### Xml.GetRoot2

`Chilkat 11.7.0 · pascal · Xml · GetRoot2 · method`

```pascal
procedure GetRoot2;
```

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 · pascal · Xml · GetSelf · method`

```pascal
// Return value is a TXml object.

function  GetSelf: TChilkatBase;
```

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 `nil` on failure

### Xml.GetXml

`Chilkat 11.7.0 · pascal · Xml · GetXml · method`

```pascal
function  GetXml: string;
```

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 · pascal · Xml · GetXmlBd · method · since 9.5.0.77`

```pascal
// bd is a TBinData object.

function  GetXmlBd(bd: TChilkatBase): Boolean;
```

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 · pascal · Xml · GetXmlSb · method · since 9.5.0.62`

```pascal
// sb is a TStringBuilder object.

function  GetXmlSb(sb: TChilkatBase): Boolean;
```

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 · pascal · Xml · HasAttribute · method`

```pascal
function  HasAttribute(const name: string): Boolean;
```

Returns `True` if the calling element has an attribute named `name`; otherwise returns `False`.

### Xml.HasAttrWithValue

`Chilkat 11.7.0 · pascal · Xml · HasAttrWithValue · method`

```pascal
function  HasAttrWithValue(const name: string;
    const value: string): Boolean;
```

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 · pascal · Xml · HasChildWithContent · method`

```pascal
function  HasChildWithContent(const content: string): Boolean;
```

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

### Xml.HasChildWithTag

`Chilkat 11.7.0 · pascal · Xml · HasChildWithTag · method`

```pascal
function  HasChildWithTag(const tagPath: string): Boolean;
```

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 · pascal · Xml · HasChildWithTagAndContent · method`

```pascal
function  HasChildWithTagAndContent(const tagPath: string;
    const content: string): Boolean;
```

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 · pascal · Xml · InsertChildTreeAfter · method`

```pascal
// tree is a TXml object.

procedure InsertChildTreeAfter(index: Integer;
    tree: TChilkatBase);
```

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 · pascal · Xml · InsertChildTreeBefore · method`

```pascal
// tree is a TXml object.

procedure InsertChildTreeBefore(index: Integer;
    tree: TChilkatBase);
```

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 · pascal · Xml · LastChild · method`

```pascal
// Return value is a TXml object.

function  LastChild: TChilkatBase;
```

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 `nil` on failure

### Xml.LastChild2

`Chilkat 11.7.0 · pascal · Xml · LastChild2 · method`

```pascal
function  LastChild2: Boolean;
```

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 · pascal · Xml · LoadBd · method · since 9.5.0.77`

```pascal
// bd is a TBinData object.

function  LoadBd(bd: TChilkatBase;
    autoTrim: Boolean): Boolean;
```

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 · pascal · Xml · LoadSb · method · since 9.5.0.62`

```pascal
// sb is a TStringBuilder object.

function  LoadSb(sb: TChilkatBase;
    autoTrim: Boolean): Boolean;
```

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 · pascal · Xml · LoadXml · method`

```pascal
function  LoadXml(const xmlData: string): Boolean;
```

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 · pascal · Xml · LoadXml2 · method`

```pascal
function  LoadXml2(const xmlData: string;
    autoTrim: Boolean): Boolean;
```

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 · pascal · Xml · LoadXmlFile · method`

```pascal
function  LoadXmlFile(const fileName: string): Boolean;
```

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 · pascal · Xml · LoadXmlFile2 · method`

```pascal
function  LoadXmlFile2(const fileName: string;
    autoTrim: Boolean): Boolean;
```

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 · pascal · Xml · NewChild · method`

```pascal
// Return value is a TXml object.

function  NewChild(const tagPath: string;
    const content: string): TChilkatBase;
```

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 `nil` on failure

### Xml.NewChild2

`Chilkat 11.7.0 · pascal · Xml · NewChild2 · method`

```pascal
procedure NewChild2(const tagPath: string;
    const content: string);
```

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 · pascal · Xml · NewChildAfter · method`

```pascal
// Return value is a TXml object.

function  NewChildAfter(index: Integer;
    const tag: string;
    const content: string): TChilkatBase;
```

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 `nil` on failure

### Xml.NewChildBefore

`Chilkat 11.7.0 · pascal · Xml · NewChildBefore · method`

```pascal
// Return value is a TXml object.

function  NewChildBefore(index: Integer;
    const tag: string;
    const content: string): TChilkatBase;
```

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 `nil` on failure

### Xml.NewChildInt2

`Chilkat 11.7.0 · pascal · Xml · NewChildInt2 · method`

```pascal
procedure NewChildInt2(const tagPath: string;
    value: Integer);
```

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 · pascal · Xml · NextInTraversal2 · method · since 9.5.0.77`

```pascal
// sbState is a TStringBuilder object.

function  NextInTraversal2(sbState: TChilkatBase): Boolean;
```

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 · pascal · Xml · NextSibling · method`

```pascal
// Return value is a TXml object.

function  NextSibling: TChilkatBase;
```

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 `nil` on failure

### Xml.NextSibling2

`Chilkat 11.7.0 · pascal · Xml · NextSibling2 · method`

```pascal
function  NextSibling2: Boolean;
```

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 · pascal · Xml · NumChildrenAt · method · since 9.5.0.64`

```pascal
function  NumChildrenAt(const tagPath: string): Integer;
```

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 · pascal · Xml · NumChildrenHavingTag · method`

```pascal
function  NumChildrenHavingTag(const tag: string): Integer;
```

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

### Xml.PreviousSibling

`Chilkat 11.7.0 · pascal · Xml · PreviousSibling · method`

```pascal
// Return value is a TXml object.

function  PreviousSibling: TChilkatBase;
```

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 `nil` on failure

### Xml.PreviousSibling2

`Chilkat 11.7.0 · pascal · Xml · PreviousSibling2 · method`

```pascal
function  PreviousSibling2: Boolean;
```

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 · pascal · Xml · PruneAttribute · method · since 9.5.0.77`

```pascal
function  PruneAttribute(const attrName: string): Integer;
```

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 · pascal · Xml · PruneTag · method · since 9.5.0.77`

```pascal
function  PruneTag(const tag: string): Integer;
```

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 · pascal · Xml · RemoveAllAttributes · method`

```pascal
function  RemoveAllAttributes: Boolean;
```

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

Returns True for success, False for failure.

### Xml.RemoveAllChildren

`Chilkat 11.7.0 · pascal · Xml · RemoveAllChildren · method`

```pascal
procedure RemoveAllChildren;
```

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 · pascal · Xml · RemoveAttribute · method`

```pascal
function  RemoveAttribute(const name: string): Boolean;
```

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 · pascal · Xml · RemoveChild · method`

```pascal
procedure RemoveChild(const tagPath: string);
```

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 · pascal · Xml · RemoveChildByIndex · method`

```pascal
procedure RemoveChildByIndex(index: Integer);
```

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

### Xml.RemoveChildWithContent

`Chilkat 11.7.0 · pascal · Xml · RemoveChildWithContent · method`

```pascal
procedure RemoveChildWithContent(const content: string);
```

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

### Xml.RemoveFromTree

`Chilkat 11.7.0 · pascal · Xml · RemoveFromTree · method`

```pascal
procedure RemoveFromTree;
```

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 · pascal · Xml · RemoveStyleSheet · method · since 9.5.0.77`

```pascal
function  RemoveStyleSheet(const attrName: string;
    const attrValue: string): Integer;
```

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 · pascal · Xml · SaveBinaryContent · method`

```pascal
function  SaveBinaryContent(const filename: string;
    unzipFlag: Boolean;
    decryptFlag: Boolean;
    const password: string): Boolean;
```

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 · pascal · Xml · SaveXml · method`

```pascal
function  SaveXml(const fileName: string): Boolean;
```

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 · pascal · Xml · Scrub · method · since 9.5.0.77`

```pascal
procedure Scrub(const directives: string);
```

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

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

```pascal
// data is a TBinData object.

function  SetBinaryContentBd(data: TChilkatBase;
    zipFlag: Boolean;
    encryptFlag: Boolean;
    const password: string): Boolean;
```

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 · pascal · Xml · SetBinaryContentFromFile · method`

```pascal
function  SetBinaryContentFromFile(const filename: string;
    zipFlag: Boolean;
    encryptFlag: Boolean;
    const password: string): Boolean;
```

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 · pascal · Xml · SortByAttribute · method`

```pascal
procedure SortByAttribute(const attrName: string;
    ascending: Boolean);
```

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 · pascal · Xml · SortByAttributeInt · method`

```pascal
procedure SortByAttributeInt(const attrName: string;
    ascending: Boolean);
```

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 · pascal · Xml · SortByContent · method`

```pascal
procedure SortByContent(ascending: Boolean);
```

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 · pascal · Xml · SortByTag · method`

```pascal
procedure SortByTag(ascending: Boolean);
```

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 · pascal · Xml · SortRecordsByAttribute · method`

```pascal
procedure SortRecordsByAttribute(const sortTag: string;
    const attrName: string;
    ascending: Boolean);
```

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 · pascal · Xml · SortRecordsByContent · method`

```pascal
procedure SortRecordsByContent(const sortTag: string;
    ascending: Boolean);
```

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 · pascal · Xml · SortRecordsByContentInt · method`

```pascal
procedure SortRecordsByContentInt(const sortTag: string;
    ascending: Boolean);
```

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 · pascal · Xml · SwapNode · method`

```pascal
// node is a TXml object.

function  SwapNode(node: TChilkatBase): Boolean;
```

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 · pascal · Xml · SwapTree · method`

```pascal
// tree is a TXml object.

function  SwapTree(tree: TChilkatBase): Boolean;
```

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 · pascal · Xml · TagContent · method`

```pascal
function  TagContent(const tagName: string): string;
```

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 · pascal · Xml · TagEquals · method`

```pascal
function  TagEquals(const tag: string): Boolean;
```

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 · pascal · Xml · TagIndex · method · since 9.5.0.76`

```pascal
function  TagIndex(const tagPath: string): Integer;
```

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 · pascal · Xml · TagNsEquals · method · since 9.5.0.77`

```pascal
function  TagNsEquals(const ns: string): Boolean;
```

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 · pascal · Xml · TagUnpEquals · method · since 9.5.0.77`

```pascal
function  TagUnpEquals(const unprefixedTag: string): Boolean;
```

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 · pascal · Xml · UnzipContent · method`

```pascal
function  UnzipContent: Boolean;
```

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 · pascal · Xml · UnzipTree · method`

```pascal
function  UnzipTree: Boolean;
```

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 · pascal · Xml · UpdateAt · method · since 9.5.0.64`

```pascal
function  UpdateAt(const tagPath: string;
    autoCreate: Boolean;
    const value: string): Boolean;
```

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 · pascal · Xml · UpdateAttrAt · method · since 9.5.0.64`

```pascal
function  UpdateAttrAt(const tagPath: string;
    autoCreate: Boolean;
    const attrName: string;
    const attrValue: string): Boolean;
```

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 · pascal · Xml · UpdateAttribute · method`

```pascal
function  UpdateAttribute(const attrName: string;
    const attrValue: string): Boolean;
```

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 · pascal · Xml · UpdateAttributeInt · method`

```pascal
function  UpdateAttributeInt(const attrName: string;
    value: Integer): Boolean;
```

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 · pascal · Xml · UpdateChildContent · method`

```pascal
procedure UpdateChildContent(const tagPath: string;
    const value: string);
```

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 · pascal · Xml · UpdateChildContentInt · method`

```pascal
procedure UpdateChildContentInt(const tagPath: string;
    value: Integer);
```

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 · pascal · Xml · ZipContent · method`

```pascal
function  ZipContent: Boolean;
```

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 · pascal · Xml · ZipTree · method`

```pascal
function  ZipTree: Boolean;
```

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.

## Related classes

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

