Xml Node.js Reference Documentation
Xml
Current Version: 10.1.0
A free non-validating XML parser component with encryption and compression features.
Object Creation
var obj = new chilkat.Xml();
Properties
Cdata
· boolean
When True, causes an XML node's content to be encapsulated in a CDATA section.
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".
ContentInt
· integer
Set/get the content as an integer.
topDebugLogFilePath
· string
If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.
This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes). A hang or crash should generally never happen. The typical causes of a hang are:
- a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,
- the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or
- there is an internal problem (bug) in the Chilkat code that causes the hang.
DocType
· string
EmitBom
· boolean
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.
topEmitCompact
· boolean
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.
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 ...".
topEncoding
· 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".
topI
· integer
Used in tagPaths (and ChilkatPath). The value of this property is substituted for "i" in "[i]". See the example below..
IsBase64
· boolean, read-only
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.
topJ
· integer
Used in tagPaths (and ChilkatPath). The value of this property is substituted for "j" in "[j]". See the example below..
K
· integer
Used in tagPaths (and ChilkatPath). The value of this property is substituted for "k" in "[k]". See the example below..
topLastErrorHtml
· string, read-only
Provides information in HTML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
topLastErrorText
· string, read-only
Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
LastErrorXml
· string, read-only
Provides information in XML format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.
topLastMethodSuccess
· boolean
Indicate whether the last method call succeeded or failed. A value of true indicates success, a value of false indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:
- Any method that returns a string.
- Any method returning a Chilkat object, binary bytes, or a date/time.
- Any method returning a standard boolean status value where success = true and failure = false.
- Any method returning an integer where failure is defined by a return value less than zero.
Note: Methods that do not fit the above requirements will always set this property equal to true. For example, a method that returns no value (such as a "void" in C++) will technically always succeed.
topNumAttributes
· integer, read-only
The number of attributes. For example, the following node has 2 attributes:
<tag attr1="value1" attr2="value2"> This is the content</tag>
NumChildren
· integer, read-only
The number of direct child nodes contained under this XML node.
topSortCaseInsensitive
· boolean
If true (or 1 for ActiveX), then all Sort* methods use case insensitive sorting.
topStandalone
· 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
· string
TagNsPrefix
· string
The node's namespace prefix, if present. For example, if the tag is "soapenv:Envelope", then this property will return "soapenv".
TagPath
· string, read-only
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.
TagUnprefixed
· string
The node's tag without the namespace prefix. For example, if the tag is "soapenv:Envelope", then this property will return "Envelope".
TreeId
· integer, 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.
topUncommonOptions
· string
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string and should typically remain empty.
topVerboseLogging
· 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.
topVersion
· string, read-only
Methods
AccumulateTagContent
· Returns a 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
AddAttribute
· Returns 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.
AddAttributeInt
· Returns Boolean (true for success, false for failure).
· name String
· value Number
AddChildTree
· Returns Boolean (true for success, false for failure).
· tree Xml
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.
AddOrUpdateAttribute
· Does not return anything (returns 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.
AddOrUpdateAttributeI
· Does not return anything (returns Undefined).
· name String
· value Number
Adds an integer attribute to an XML node. If an attribute having the specified name already exists, the value is updated.
topAddStyleSheet
· Does not return anything (returns 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
· Does not return anything (returns Undefined).
· name String
· amount Number
Adds an integer amount to an integer attribute's value. If the attribute does not yet exist, this method behaves the same as AddOrUpdateAttributeI.
AddToChildContent
· Does not return anything (returns Undefined).
· tag String
· amount Number
Adds an integer value to the content of a child node.
topAddToContent
· Does not return anything (returns Undefined).
· amount Number
Adds an integer amount to the node's content.
topAppendToContent
· Returns Boolean (true for success, false for failure).
· str String
BEncodeContent
· Returns Boolean (true for success, false for failure).
· charset String
· inData Buffer
Sets the node's content with 8bit data that is in a specified multibyte character encoding such as utf-8, shift-jis, big5, etc. The data is first B-encoded and the content is set to be the B-encoded string. For example, if called with "Big5"for the charset, you would get a string that looks something like this: "=?Big5?B?pHCtsw==?=". The data is Base64-encoded and stored between the last pair of "?" delimiters. Use the DecodeContent method to retrieve the byte data from a B encoded string.
Returns true for success, false for failure.
topChildContentMatches
· Returns a 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".
topChilkatPath
· Returns a 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:
- TagName -- Navigate to the 1st direct child with the given tag.
- TagName[n] -- Navigate to the Nth direct child with the given tag.
- ".." -- Navigate up to the parent.
- "++" -- Navigate to the next sibling. (next/previous sibling feature added in v9.5.0.76)
- "--" -- Navigate to the previous sibling.
- TagName{Content} -- Navigate to the 1st direct child with the given tag having the exact content.
- /T/TagName -- Traverse the XML DOM tree (rooted at the caller) and navigate to the 1st node having the given tag.
- /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.
- /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.
- /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.
- * -- Return the Content of the node.
- (AttrName) -- Return the value of the given attribute.
- $ -- 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
Clear
· Does not return anything (returns Undefined).
Removes all children, attributes, and content from the XML node. Resets the tag name to "unnamed".
topContentMatches
· Returns a Boolean.
· pattern String
· caseSensitive Boolean
Return true if the node's content matches a wildcarded pattern.
topCopy
· Does not return anything (returns Undefined).
· node Xml
Copies the tag, content, and attributes to the calling node.
topCopyRef
· Does not return anything (returns Undefined).
· copyFromNode Xml
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.
topDecodeContent
· Returns a Buffer.
Decodes a node's Q or B-encoded content string and returns the byte data.
Returns null on failure
topDecodeEntities
· Returns a 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
DecryptContent
· Returns 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.
EncryptContent
· Returns 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.
ExtractChildByIndex
· Returns a Xml
· index Number
Removes and returns the Nth child of an XML node. The first child is at index 0.
Returns null on failure
topExtractChildByName
· Returns a Xml
· tagPath String
· attrName String
· attrValue String
Removes and returns the first child node at the specified tag or tag path. The attrName and attrValue may be empty, in which case the first child matching the tag is removed and returned. If attrName is specified, then the first child having a tag equal to tagPath, and an attribute with attrName is returned. If attrValue is also specified, then only a child having a tag equal to tagPath, and an attribute named attrName, with a value equal to attrValue is returned.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
FindChild
· Returns a Xml
· tagPath String
Returns the child with the given tag or at the specified tag path.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
FindChild2
· Returns 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.
FindNextRecord
· Returns a Xml
· tagPath String
· contentPattern String
Returns the next record node where the child with a specific tag matches a wildcarded pattern. This method makes it easy to iterate over high-level records.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
FindOrAddNewChild
· Returns a Xml
· tagPath String
First checks for a child at tagPath, and if found, returns it. Otherwise creates a new child with empty content.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
topFirstChild
· Returns a Xml
Returns the first child. A program can step through the children by calling FirstChild, and then NextSibling repeatedly.
Returns null on failure
FirstChild2
· Returns 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.
GetAttributeName
· Returns a String.
· index Number
Returns the name of the Nth attribute of an XML node. The first attribute is at index 0.
Returns null on failure
GetAttributeValue
· Returns a String.
· index Number
Returns the value of the Nth attribute of an XML node. The first attribute is at index 0.
Returns null on failure
GetAttributeValueInt
· Returns a Number.
· index Number
Returns an attribute as an integer. Returns 0 if the attribute does not exist.
topGetAttrValue
· Returns a String.
· name String
Find and return the value of an attribute having a specified name.
Returns null on failure
GetAttrValueInt
· Returns a Number.
· name String
Returns an attribute as an integer. Returns 0 if the attribute does not exist.
GetBinaryContent
· Returns a Buffer.
Returns binary content of an XML node as a byte array. The content may have been Zip compressed, AES encrypted, or both. Unzip compression and AES decryption flags should be set appropriately.
Returns null on failure
topGetChild
· Returns a Xml
· index Number
GetChild2
· Returns Boolean (true for success, false for failure).
· index Number
Updates the calling object's internal reference to the Nth child node.
Returns true for success, false for failure.
GetChildAttrValue
· Returns a String.
· tagPath String
· attrName String
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
topGetChildBoolValue
· Returns a 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".
GetChildContent
· Returns a 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
GetChildContentByIndex
· Returns a String.
· index Number
GetChildContentSb
· Returns Boolean (true for success, false for failure).
· tagPath String
· sb StringBuilder
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.
GetChildExact
· Returns a Xml
· tag String
· content String
GetChildIntValue
· Returns a Number.
· 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".
GetChildTag
· Returns a String.
· index Number
GetChildTagByIndex
· Returns a String.
· index Number
Returns the tag name of the Nth child node.
Returns null on failure
GetChildWithAttr
· Returns a Xml
· tagPath String
· attrName String
· attrValue String
Finds and returns the XML child node having both a given tag and an attribute with a given name and value.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
GetChildWithContent
· Returns a Xml
· content String
GetChildWithTag
· Returns a Xml
· tagPath String
Returns the child at the specified tag or tag path.
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "tagA|tagB|tagC".
Returns null on failure
topGetNthChildWithTag
· Returns a Xml
· tag String
· n Number
Returns the Nth child having a tag that matches exactly with the tagName. Use the NumChildrenHavingTag method to determine how many children have a particular tag.
Returns null on failure
GetNthChildWithTag2
· Returns Boolean (true for success, false for failure).
· tag String
· n Number
Updates the calling object's internal reference to the Nth child node having a specific tag.
Returns true for success, false for failure.
GetParent
· Returns a Xml
Returns the parent of this XML node, or NULL if the node is the root of the tree.
Returns null on failure
topGetParent2
· Returns Boolean (true for success, false for failure).
Updates the internal reference of the caller to its parent.
Returns true for success, false for failure.
GetRoot
· Returns a Xml
GetRoot2
· Does not return anything (returns Undefined).
Updates the internal reference of the caller to the document root.
GetSelf
· Returns a Xml
GetXml
· Returns a 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
topGetXmlBd
· Returns Boolean (true for success, false for failure).
· bd BinData
GetXmlSb
· Returns Boolean (true for success, false for failure).
· sb StringBuilder
Emits the XML to a StringBuilder object. (Appends to the existing contents of sb.)
Returns true for success, false for failure.
topHasAttribute
· Returns a Boolean.
· name String
Returns true if the node contains an attribute with the specified name.
topHasAttrWithValue
· Returns a Boolean.
· name String
· value String
Returns true if the node contains attribute with the name and value.
topHasChildWithContent
· Returns a Boolean.
· content String
Returns true if the node has a direct child node containing the exact content string specified.
topHasChildWithTag
· Returns a 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".
HasChildWithTagAndContent
· Returns a 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".
topInsertChildTreeAfter
· Does not return anything (returns Undefined).
· index Number
· tree Xml
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).
InsertChildTreeBefore
· Does not return anything (returns Undefined).
· index Number
· tree Xml
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).
LastChild
· Returns a Xml
Returns the last Xml child node. A node's children can be enumerated by calling LastChild and then repeatedly calling PreviousSibling, until a NULL is returned.
Returns null on failure
LastChild2
· Returns 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.
LoadBd
· Returns Boolean (true for success, false for failure).
· bd BinData
· autoTrim Boolean
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.
topLoadSb
· Returns Boolean (true for success, false for failure).
· sb StringBuilder
· autoTrim Boolean
Loads XML from the contents of a StringBuilder object.
Returns true for success, false for failure.
LoadXml
· Returns 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.
topLoadXml2
· Returns 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.
LoadXmlFile
· Returns 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.
LoadXmlFile2
· Returns 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.
NewChild
· Returns a Xml
· tagPath String
· content String
Creates a new child having tag and content. The new child is created even if a child with a tag equal to tagPath already exists. (Use FindOrAddNewChild to prevent creating children having the same tags.)
Beginning in version 9.5.0.64, the tagPath can be a tag path. A tag path is a series of tags separated by vertical bar characters. For example: "colors|primary|red". See the example below for details.
Returns null on failure
NewChild2
· Does not return anything (returns 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.
NewChildAfter
· Returns a Xml
· index Number
· tag String
· content String
Inserts a new child in a position after the Nth child node.
Returns null on failure
NewChildBefore
· Returns a Xml
· index Number
· tag String
· content String
Inserts a new child in a position before the Nth child node.
Returns null on failure
NewChildInt2
· Does not return anything (returns Undefined).
· tagPath String
· value Number
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.
NextInTraversal2
· Returns a Boolean.
· sbState StringBuilder
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.
NextSibling
· Returns a Xml
Returns the nodes next sibling, or NULL if there are no more.
Returns null on failure
NextSibling2
· Returns 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.
NumChildrenAt
· Returns a Number.
· tagPath String
Returns the number of children for the node indicated by tagPath. Returns -1 if the node at tagPath does not exist.
NumChildrenHavingTag
· Returns a Number.
· tag String
PreviousSibling
· Returns a Xml
Returns the Xml object that is the node's previous sibling, or NULL if there are no more.
Returns null on failure
PreviousSibling2
· Returns 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.
PruneAttribute
· Returns a Number.
· attrName String
Recursively descends the XML from this node and removes all occurrences of the specified attribute. Returns the number of attribute occurrences removed.
topPruneTag
· Returns a Number.
· tag String
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.
QEncodeContent
· Returns Boolean (true for success, false for failure).
· charset String
· inData Buffer
Sets the node's content with 8bit data that is in a specified multibyte character encoding such as utf-8, shift-jis, big5, etc. The data is first Q-encoded and the content is set to be the Q-encoded string. For example, if called with "gb2312"for the charset, you would get a string that looks something like this: "=?gb2312?Q?=C5=B5=BB=F9?=". Character that are not 7bit are represented as "=XX" where XX is the hexidecimal value of the byte. Use the DecodeContent method to retrieve the byte data from a Q encoded string.
Returns true for success, false for failure.
topRemoveAllAttributes
· Returns 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.
topRemoveAllChildren
· Does not return anything (returns Undefined).
Removes all children from the calling node.
topRemoveAttribute
· Returns Boolean (true for success, false for failure).
· name String
RemoveChild
· Does not return anything (returns 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".
RemoveChildByIndex
· Does not return anything (returns Undefined).
· index Number
RemoveChildWithContent
· Does not return anything (returns Undefined).
· content String
RemoveFromTree
· Does not return anything (returns Undefined).
Removes the calling object and its sub-tree from the XML document making it the root of its own tree.
RemoveStyleSheet
· Returns a Number.
· attrName String
· attrValue String
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.
topSaveBinaryContent
· Returns Boolean (true for success, false for failure).
· filename String
· unzipFlag Boolean
· decryptFlag Boolean
· password String
SaveXml
· Returns 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.
topScrub
· Does not return anything (returns Undefined).
· directives String
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.
SearchAllForContent
· Returns a Xml
· afterPtr Xml
· contentPattern String
Returns the first node having content matching the contentPattern. The contentPattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to null. (For the ActiveX implementation, the afterPtr should never be null. A reference to the caller's node should be passed instead.)
To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchAllForContent, until the method returns null.
Returns null on failure
SearchAllForContent2
· Returns Boolean (true for success, false for failure).
· afterPtr Xml
· contentPattern String
Same as SearchAllForContent except the internal reference of the caller is updated to point to the search result (instead of returning a new object).
Returns true for success, false for failure.
topSearchForAttribute
· Returns a Xml
· afterPtr Xml
· tag String
· attr String
· valuePattern String
Returns the first node having a tag equal to tag, an attribute named attr, whose value matches valuePattern. The valuePattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to null. (For the ActiveX implementation, the afterPtr should never be null. A reference to the caller's node should be passed instead.)
To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForAttribute, until the method returns null.
Returns null on failure
SearchForAttribute2
· Returns Boolean (true for success, false for failure).
· afterPtr Xml
· tag String
· attr String
· valuePattern String
Same as SearchForAttribute except the internal reference of the caller is updated to point to the search result (instead of returning a new object).
Returns true for success, false for failure.
topSearchForContent
· Returns a Xml
· afterPtr Xml
· tag String
· contentPattern String
Returns the first node having a tag equal to tag, whose content matches contentPattern. The contentPattern is a case-sensitive string that may contain any number of '*'s, each representing 0 or more occurrences of any character. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to null. (For the ActiveX implementation, the afterPtr should never be null. A reference to the caller's node should be passed instead.)
To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForContent, until the method returns null.
Returns null on failure
SearchForContent2
· Returns Boolean (true for success, false for failure).
· afterPtr Xml
· tag String
· contentPattern String
Same as SearchForContent except the internal reference of the caller is updated to point to the search result (instead of returning a new object).
Returns true for success, false for failure.
SearchForTag
· Returns a Xml
· afterPtr Xml
· tag String
Returns the first node having a tag equal to tag. The search is breadth-first over the sub-tree rooted at the caller. A match is returned only after the search has traversed past the node indicated by afterPtr. To find the 1st occurrence, set afterPtr equal to null. (For the ActiveX implementation, the afterPtr should never be null. A reference to the caller's node should be passed instead.)
To iterate over matching nodes, the returned node can be passed in afterPtr for the next call to SearchForTag, until the method returns null.
Returns null on failure
SearchForTag2
· Returns Boolean (true for success, false for failure).
· afterPtr Xml
· tag String
Same as SearchForTag except the internal reference of the caller is updated to point to the search result (instead of returning a new object).
Returns true for success, false for failure.
SetBinaryContent
· Returns Boolean (true for success, false for failure).
· inData Buffer
· zipFlag Boolean
· encryptFlag Boolean
· password String
Sets the node's content to a block of binary data with optional Zip compression and/or AES encryption. The binary data is automatically converted to base64 format whenever XML text is generated. If the zipFlag is True, the data is first compressed. If the encryptFlag is True, the data is AES encrypted using the Rijndael 128-bit symmetric-encryption algorithm.
Returns true for success, false for failure.
topSetBinaryContentFromFile
· Returns 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.
topSortByAttribute
· Does not return anything (returns Undefined).
· attrName String
· ascending Boolean
Sorts the direct child nodes by the value of a specified attribute.
topSortByAttributeInt
· Does not return anything (returns 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).
topSortByContent
· Does not return anything (returns Undefined).
· ascending Boolean
SortByTag
· Does not return anything (returns Undefined).
· ascending Boolean
SortRecordsByAttribute
· Does not return anything (returns Undefined).
· sortTag String
· attrName String
· ascending Boolean
Sorts the direct child nodes by the content of an attribute in the grandchild nodes.
topSortRecordsByContent
· Does not return anything (returns Undefined).
· sortTag String
· ascending Boolean
Sorts the direct child nodes by the content of the grandchild nodes.
SortRecordsByContentInt
· Does not return anything (returns 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).
topSwapNode
· Returns Boolean (true for success, false for failure).
· node Xml
Swaps another node's tag, content, and attributes with this one.
Returns true for success, false for failure.
topSwapTree
· Returns Boolean (true for success, false for failure).
· tree Xml
Swaps another node's tag, content, attributes, and children with this one.
Returns true for success, false for failure.
topTagContent
· Returns a 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
topTagEquals
· Returns a Boolean.
· tag String
Returns true if the node's tag equals the specified string.
topTagIndex
· Returns a Number.
· tagPath String
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.
TagNsEquals
· Returns a Boolean.
· ns String
Returns true if the node's tag namespace prefix equals the specified ns.
TagUnpEquals
· Returns a Boolean.
· unprefixedTag String
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".
UnzipContent
· Returns 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.
UnzipTree
· Returns 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.
UpdateAt
· Returns a Boolean.
· tagPath String
· autoCreate Boolean
· value String
Updates the content for the node indicated by tagPath. If autoCreate is true, then nodes along tagPath are auto-created as needed.
UpdateAttrAt
· Returns a Boolean.
· tagPath String
· autoCreate Boolean
· attrName String
· attrValue String
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.
UpdateAttribute
· Returns 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.
UpdateAttributeInt
· Returns Boolean (true for success, false for failure).
· attrName String
· value Number
Updates an attribute value. (Call UpdateAttribute if the attribute value is a string.)
Returns true for success, false for failure.
topUpdateChildContent
· Does not return anything (returns 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.
UpdateChildContentInt
· Does not return anything (returns Undefined).
· tagPath String
· value Number
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".
topZipContent
· Returns 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.
ZipTree
· Returns 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.