Xml JavaScript Reference Documentation

Xml

Current Version: 11.4.0

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

Object Creation

Note: This is intended for running within a Chilkat.Js embedded JavaScript engine.

var obj = new CkXml();

Properties

Cdata
Cdata
· boolean

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

top
Content
Content
· string

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

<tag1>This is the content</tag1>

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

top
ContentInt
ContentInt
· int

Set/get the content as an integer.

top
DebugLogFilePath
DebugLogFilePath
· string

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
DocType
DocType
· string

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

More Information and Examples
top
EmitBom
EmitBom
· boolean
Introduced in version 9.5.0.44

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

top
EmitCompact
EmitCompact
· boolean
Introduced in version 9.5.0.64

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

More Information and Examples
top
EmitXmlDecl
EmitXmlDecl
· boolean

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

top
Encoding
Encoding
· string

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

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

top
I
I
· int
Introduced in version 9.5.0.64

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

top
IsBase64
IsBase64
· boolean, read-only
Introduced in version 9.5.0.76

Returns true if the content contains only those characters allowed in the base64 encoding. A base64 string is composed of characters 'A'..'Z', 'a'..'z', '0'..'9', '+', '/' and it is often padded at the end with up to two '=', to make the length a multiple of 4. Whitespace is ignored.

top
J
J
· int
Introduced in version 9.5.0.64

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

More Information and Examples
top
K
K
· int
Introduced in version 9.5.0.64

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

top
LastErrorHtml
LastErrorHtml
· string, read-only

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
LastErrorText
· string, read-only

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
LastErrorXml
· string, read-only

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
LastMethodSuccess
· boolean

Indicates the success or failure of the most recent method call: true means success, false means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
NumAttributes
NumAttributes
· int, read-only

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

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

top
NumChildren
NumChildren
· int, read-only

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

top
SortCaseInsensitive
SortCaseInsensitive
· boolean

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

top
Standalone
Standalone
· boolean

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

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

top
Tag
Tag
· string

The XML node's tag, including the namespace prefix.

More Information and Examples
top
TagNsPrefix
TagNsPrefix
· string
Introduced in version 9.5.0.77

The node's namespace prefix, if present. For example, if the tag is soapenv:Envelope, then this property will return soapenv.

top
TagPath
TagPath
· string, read-only
Introduced in version 9.5.0.77

Returns the path to reach this element from the XML document root. If the caller is the document root, then the empty string is returned.

top
TagUnprefixed
TagUnprefixed
· string
Introduced in version 9.5.0.77

The node's tag without the namespace prefix. For example, if the tag is soapenv:Envelope, then this property will return Envelope.

top
TreeId
TreeId
· int, read-only

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

top
UncommonOptions
UncommonOptions
· string
Introduced in version 9.5.0.90

This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.

top
VerboseLogging
VerboseLogging
· boolean

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

top
Version
Version
· string, read-only

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

More Information and Examples
top

Methods

AccumulateTagContent
var strVal = AccumulateTagContent(tag, skipTags);
· return: string
· tag: string
· skipTags: string

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

Returns null on failure

More Information and Examples
top
AddAttribute
var success = AddAttribute(name, value);
· return: boolean; true for success, false for failure
· name: string
· value: string

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

Returns true for success, false for failure.

top
AddAttributeInt
var success = AddAttributeInt(name, value);
· return: boolean; true for success, false for failure
· name: string
· value: int

Adds an integer attribute to a node.

Returns true for success, false for failure.

top
AddChildTree
var success = AddChildTree(tree);
· return: boolean; true for success, false for failure
· tree: CkXml

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

Returns true for success, false for failure.

More Information and Examples
top
AddOrUpdateAttribute
AddOrUpdateAttribute(name, value);
· return: undefined
· name: string
· value: string

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

More Information and Examples
top
AddOrUpdateAttributeI
AddOrUpdateAttributeI(name, value);
· return: undefined
· name: string
· value: int

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

top
AddStyleSheet
AddStyleSheet(styleSheet);
· return: undefined
· styleSheet: string

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

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

top
AddToAttribute
AddToAttribute(name, amount);
· return: undefined
· name: string
· amount: int

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

More Information and Examples
top
AddToChildContent
AddToChildContent(tag, amount);
· return: undefined
· tag: string
· amount: int

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

top
AddToContent
AddToContent(amount);
· return: undefined
· amount: int

Adds an integer amount to the node's content.

top
AppendToContent
var success = AppendToContent(str);
· return: boolean; true for success, false for failure
· str: string

Appends text to the content of an XML node

Returns true for success, false for failure.

top
ChildContentMatches
var boolVal = ChildContentMatches(tagPath, pattern, caseSensitive);
· return: boolean
· tagPath: string
· pattern: string
· caseSensitive: boolean

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

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

top
ChilkatPath
var strVal = ChilkatPath(pathCmd);
· return: string
· pathCmd: string

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

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

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

    command|command|command|...|returnCommand

A command can be any of the following:

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

Returns null on failure

top
Clear
Clear();
· return: undefined

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

top
ContentMatches
var boolVal = ContentMatches(pattern, caseSensitive);
· return: boolean
· pattern: string
· caseSensitive: boolean

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

top
Copy
Copy(node);
· return: undefined
· node: CkXml

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

top
CopyRef
CopyRef(copyFromNode);
· return: undefined
· copyFromNode: CkXml

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

top
DecodeEntities
var strVal = DecodeEntities(str);
· return: string
· str: string

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

Returns null on failure

More Information and Examples
top
DecryptContent
var success = DecryptContent(password);
· return: boolean; true for success, false for failure
· password: string

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

Returns true for success, false for failure.

More Information and Examples
top
EncryptContent
var success = EncryptContent(password);
· return: boolean; true for success, false for failure
· password: string

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

Returns true for success, false for failure.

More Information and Examples
top
FindChild2
var success = FindChild2(tagPath);
· return: boolean; true for success, false for failure
· tagPath: string

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

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

Returns true for success, false for failure.

top
FirstChild2
var success = FirstChild2();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

top
GetAttributeName
var strVal = GetAttributeName(index);
· return: string
· index: int

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

Returns null on failure

top
GetAttributeValue
var strVal = GetAttributeValue(index);
· return: string
· index: int

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

Returns null on failure

top
GetAttributeValueInt
var intVal = GetAttributeValueInt(index);
· return: int
· index: int

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

top
GetAttrValue
var strVal = GetAttrValue(name);
· return: string
· name: string

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

Returns null on failure

top
GetAttrValueInt
var intVal = GetAttrValueInt(name);
· return: int
· name: string

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

top
GetChild2
var success = GetChild2(index);
· return: boolean; true for success, false for failure
· index: int

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

Returns true for success, false for failure.

top
GetChildAttrValue
var strVal = GetChildAttrValue(tagPath, attrName);
· return: string
· tagPath: string
· attrName: string
Introduced in version 9.5.0.77

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

Returns null on failure

top
GetChildBoolValue
var boolVal = GetChildBoolValue(tagPath);
· return: boolean
· tagPath: string

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

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

More Information and Examples
top
GetChildContent
var strVal = GetChildContent(tagPath);
· return: string
· tagPath: string

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

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

Returns null on failure

More Information and Examples
top
GetChildContentByIndex
var strVal = GetChildContentByIndex(index);
· return: string
· index: int

Returns the content of the Nth child node.

Returns null on failure

More Information and Examples
top
GetChildContentSb
var success = GetChildContentSb(tagPath, sb);
· return: boolean; true for success, false for failure
· tagPath: string
· sb: CkStringBuilder
Introduced in version 9.5.0.76

Returns the content of the XML element at the tagPath. The XML element's content is appended to the sb.

Returns true for success, false for failure.

top
GetChildIntValue
var intVal = GetChildIntValue(tagPath);
· return: int
· tagPath: string

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

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

More Information and Examples
top
GetChildTag
var strVal = GetChildTag(index);
· return: string
· index: int

Returns the tag name of the Nth child node.

Returns null on failure

top
GetChildTagByIndex
var strVal = GetChildTagByIndex(index);
· return: string
· index: int

Returns the tag name of the Nth child node.

Returns null on failure

top
GetChildWithTag2
var success = GetChildWithTag2(tagPath);
· return: boolean; true for success, false for failure
· tagPath: string
Introduced in version 11.1.0

Updates the calling object's internal reference to the child at the specified tag or tag path.

The tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: tagA|tagB|tagC.

Returns true for success, false for failure.

top
GetNthChildWithTag2
var success = GetNthChildWithTag2(tag, n);
· return: boolean; true for success, false for failure
· tag: string
· n: int

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

Returns true for success, false for failure.

top
GetParent2
var success = GetParent2();
· return: boolean; true for success, false for failure

Updates the internal reference of the caller to its parent.

Returns true for success, false for failure.

top
GetRoot2
GetRoot2();
· return: undefined

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

top
GetXml
var strVal = GetXml();
· return: string

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

Returns null on failure

top
GetXmlBd
var success = GetXmlBd(bd);
· return: boolean; true for success, false for failure
· bd: CkBinData
Introduced in version 9.5.0.77

Emits (appends) the XML to the contents of bd.

Returns true for success, false for failure.

top
GetXmlSb
var success = GetXmlSb(sb);
· return: boolean; true for success, false for failure
· sb: CkStringBuilder
Introduced in version 9.5.0.62

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

Returns true for success, false for failure.

top
HasAttribute
var boolVal = HasAttribute(name);
· return: boolean
· name: string

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

top
HasAttrWithValue
var boolVal = HasAttrWithValue(name, value);
· return: boolean
· name: string
· value: string

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

top
HasChildWithContent
var boolVal = HasChildWithContent(content);
· return: boolean
· content: string

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

top
HasChildWithTag
var boolVal = HasChildWithTag(tagPath);
· return: boolean
· tagPath: string

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

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

More Information and Examples
top
HasChildWithTagAndContent
var boolVal = HasChildWithTagAndContent(tagPath, content);
· return: boolean
· tagPath: string
· content: string

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

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

top
InsertChildTreeAfter
InsertChildTreeAfter(index, tree);
· return: undefined
· index: int
· tree: CkXml

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

top
InsertChildTreeBefore
InsertChildTreeBefore(index, tree);
· return: undefined
· index: int
· tree: CkXml

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

top
LastChild2
var success = LastChild2();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

top
LoadBd
var success = LoadBd(bd, autoTrim);
· return: boolean; true for success, false for failure
· bd: CkBinData
· autoTrim: boolean
Introduced in version 9.5.0.77

Loads XML from the contents of bd. If autoTrim is true, then each element's text content is trimmed of leading and trailing whitespace.

Returns true for success, false for failure.

top
LoadSb
var success = LoadSb(sb, autoTrim);
· return: boolean; true for success, false for failure
· sb: CkStringBuilder
· autoTrim: boolean
Introduced in version 9.5.0.62

Loads XML from the contents of a StringBuilder object.

Returns true for success, false for failure.

More Information and Examples
top
LoadXml
var success = LoadXml(xmlData);
· return: boolean; true for success, false for failure
· xmlData: string

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

Returns true for success, false for failure.

top
LoadXml2
var success = LoadXml2(xmlData, autoTrim);
· return: boolean; true for success, false for failure
· xmlData: string
· autoTrim: boolean

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

Returns true for success, false for failure.

More Information and Examples
top
LoadXmlFile
var success = LoadXmlFile(fileName);
· return: boolean; true for success, false for failure
· fileName: string

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

Returns true for success, false for failure.

top
LoadXmlFile2
var success = LoadXmlFile2(fileName, autoTrim);
· return: boolean; true for success, false for failure
· fileName: string
· autoTrim: boolean

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

Returns true for success, false for failure.

More Information and Examples
top
NewChild2
NewChild2(tagPath, content);
· return: undefined
· tagPath: string
· content: string

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

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

More Information and Examples
top
NewChildInt2
NewChildInt2(tagPath, value);
· return: undefined
· tagPath: string
· value: int

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

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

More Information and Examples
top
NextInTraversal2
var boolVal = NextInTraversal2(sbState);
· return: boolean
· sbState: CkStringBuilder
Introduced in version 9.5.0.77

Updates to Xml object's internal reference to the next node in a depth-first traversal. (This method name, NextInTraversal2, ends with 2 to signify that the internal reference is updated. There is no NextInTraversal method.)

The sbState contains the current state of the traversal. sbState should be empty when beginning a traversal.

More Information and Examples
top
NextSibling2
var success = NextSibling2();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

top
NumChildrenAt
var intVal = NumChildrenAt(tagPath);
· return: int
· tagPath: string
Introduced in version 9.5.0.64

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

top
NumChildrenHavingTag
var intVal = NumChildrenHavingTag(tag);
· return: int
· tag: string

Returns the number of children having a specific tag name.

top
PreviousSibling2
var success = PreviousSibling2();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

top
PruneAttribute
var intVal = PruneAttribute(attrName);
· return: int
· attrName: string
Introduced in version 9.5.0.77

Recursively descends the XML from this node and removes all occurrences of the specified attribute. Returns the number of attribute occurrences removed.

top
PruneTag
var intVal = PruneTag(tag);
· return: int
· tag: string
Introduced in version 9.5.0.77

Recursively descends the XML from this node and removes all occurrences of the specified tag, including all descendents of each removed node. Returns the number of tag occurrences removed.

More Information and Examples
top
RemoveAllAttributes
var success = RemoveAllAttributes();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

top
RemoveAllChildren
RemoveAllChildren();
· return: undefined

Removes all children from the calling node.

top
RemoveAttribute
var success = RemoveAttribute(name);
· return: boolean; true for success, false for failure
· name: string

Removes an attribute by name from and XML node.

Returns true for success, false for failure.

top
RemoveChild
RemoveChild(tagPath);
· return: undefined
· tagPath: string

Removes all children with a given tag or tag path.

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

More Information and Examples
top
RemoveChildByIndex
RemoveChildByIndex(index);
· return: undefined
· index: int

Removes the Nth child from the calling node.

top
RemoveChildWithContent
RemoveChildWithContent(content);
· return: undefined
· content: string

Removes all children having the exact content specified.

top
RemoveFromTree
RemoveFromTree();
· return: undefined

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

top
RemoveStyleSheet
var intVal = RemoveStyleSheet(attrName, attrValue);
· return: int
· attrName: string
· attrValue: string
Introduced in version 9.5.0.77

Removes all XML stylesheets having an attribute with attrName equal to attrValue. Returns the number of stylesheets removed, or -1 if there was an error.

top
SaveBinaryContent
var success = SaveBinaryContent(filename, unzipFlag, decryptFlag, password);
· return: boolean; true for success, false for failure
· filename: string
· unzipFlag: boolean
· decryptFlag: boolean
· password: string

Saves a node's binary content to a file.

Returns true for success, false for failure.

top
SaveXml
var success = SaveXml(fileName);
· return: boolean; true for success, false for failure
· fileName: string

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

Returns true for success, false for failure.

top
Scrub
Scrub(directives);
· return: undefined
· directives: string
Introduced in version 9.5.0.77

Recursively traverses the XML rooted at the caller and scrubs according to the instructions in the comma separated directives. The currently defined directives are:

  • AttrTrimEnds - Leading and trailing whitespace removed from attribute values.
  • AttrTrimInside - Replace all tabs, CR's, and LF's with SPACE chars, and removes extra SPACE chars so that no more than one SPACE char in a row exists.
  • ContentTrimEnds - Same as AttrTrimEnds but for content.
  • ContentTrimInside - Same as AttrTrimInside but for content.
  • LowercaseAttrs - Convert all attribute names to lowercase.
  • LowercaseTags - Convert all tags to lowercase.
  • RemoveCtrl - Remove non-printable us-ascii control chars (us-ascii values <= 31 except for TAB,CR, and LF are removed)

If you have other ideas for useful XML scrubbing directives, send email to support@chilkatsoft.com. It must be general enough such that many developers will find it useful.

More Information and Examples
top
SetBinaryContentBd
var success = SetBinaryContentBd(data, zipFlag, encryptFlag, password);
· return: boolean; true for success, false for failure
· data: CkBinData
· zipFlag: boolean
· encryptFlag: boolean
· password: string
Introduced in version 11.0.0

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

Returns true for success, false for failure.

top
SetBinaryContentFromFile
var success = SetBinaryContentFromFile(filename, zipFlag, encryptFlag, password);
· return: boolean; true for success, false for failure
· filename: string
· zipFlag: boolean
· encryptFlag: boolean
· password: string

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

Returns true for success, false for failure.

top
SortByAttribute
SortByAttribute(attrName, ascending);
· return: undefined
· attrName: string
· ascending: boolean

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

top
SortByAttributeInt
SortByAttributeInt(attrName, ascending);
· return: undefined
· attrName: string
· ascending: boolean

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

top
SortByContent
SortByContent(ascending);
· return: undefined
· ascending: boolean

Sorts the direct child nodes by content.

top
SortByTag
SortByTag(ascending);
· return: undefined
· ascending: boolean

Sorts the direct child nodes by tag.

top
SortRecordsByAttribute
SortRecordsByAttribute(sortTag, attrName, ascending);
· return: undefined
· sortTag: string
· attrName: string
· ascending: boolean

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

top
SortRecordsByContent
SortRecordsByContent(sortTag, ascending);
· return: undefined
· sortTag: string
· ascending: boolean

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

top
SortRecordsByContentInt
SortRecordsByContentInt(sortTag, ascending);
· return: undefined
· sortTag: string
· ascending: boolean

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

top
SwapNode
var success = SwapNode(node);
· return: boolean; true for success, false for failure
· node: CkXml

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

Returns true for success, false for failure.

top
SwapTree
var success = SwapTree(tree);
· return: boolean; true for success, false for failure
· tree: CkXml

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

Returns true for success, false for failure.

top
TagContent
var strVal = TagContent(tagName);
· return: string
· tagName: string

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

Returns null on failure

top
TagEquals
var boolVal = TagEquals(tag);
· return: boolean
· tag: string

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

top
TagIndex
var intVal = TagIndex(tagPath);
· return: int
· tagPath: string
Introduced in version 9.5.0.76

Returns the index of the XML node with the given tag. Returns -1 if no node having the specified tag is found at the tagPath.

top
TagNsEquals
var boolVal = TagNsEquals(ns);
· return: boolean
· ns: string
Introduced in version 9.5.0.77

Returns true if the node's tag namespace prefix equals the specified ns.

top
TagUnpEquals
var boolVal = TagUnpEquals(unprefixedTag);
· return: boolean
· unprefixedTag: string
Introduced in version 9.5.0.77

Returns true if the node's unprefixed tag equals the specified string. For example, if the tag is soapenv:Body, the unprefixed tag is Body.

top
UnzipContent
var success = UnzipContent();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

More Information and Examples
top
UnzipTree
var success = UnzipTree();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

More Information and Examples
top
UpdateAt
var boolVal = UpdateAt(tagPath, autoCreate, value);
· return: boolean
· tagPath: string
· autoCreate: boolean
· value: string
Introduced in version 9.5.0.64

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

More Information and Examples
top
UpdateAttrAt
var boolVal = UpdateAttrAt(tagPath, autoCreate, attrName, attrValue);
· return: boolean
· tagPath: string
· autoCreate: boolean
· attrName: string
· attrValue: string
Introduced in version 9.5.0.64

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

top
UpdateAttribute
var success = UpdateAttribute(attrName, attrValue);
· return: boolean; true for success, false for failure
· attrName: string
· attrValue: string

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

Returns true for success, false for failure.

More Information and Examples
top
UpdateAttributeInt
var success = UpdateAttributeInt(attrName, value);
· return: boolean; true for success, false for failure
· attrName: string
· value: int

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

Returns true for success, false for failure.

top
UpdateChildContent
UpdateChildContent(tagPath, value);
· return: undefined
· tagPath: string
· value: string

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

Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: tagA|tagB|tagC. The nodes in the tagPath are automatically created as needed.

top
UpdateChildContentInt
UpdateChildContentInt(tagPath, value);
· return: undefined
· tagPath: string
· value: int

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

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

top
ZipContent
var success = ZipContent();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

More Information and Examples
top
ZipTree
var success = ZipTree();
· return: boolean; true for success, false for failure

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

Returns true for success, false for failure.

More Information and Examples
top