AspXml ActiveX Reference (Visual Basic)

AspXml

Properties

Cdata As Long

When equal to 1, the Content is encapsulated in a CDATA section.

Content As String

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

Encoding As String

The encoding attribute in the XML declaration. If not present, then this property returns an empty string. This property can be set from any node in the XML document and when set, causes the encoding property to be added to the XML declaration. Setting this property causes the document to be converted to the encoding when saved.

LastErrorHtml As String (read-only)

Error information in HTML format for the last method called.

LastErrorText As String (read-only)

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

LastErrorXml As String (read-only)

Error information in XML format for the last method called.

NumAttributes As Long (read-only)

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

NumChildren As Long (read-only)

The number of child nodes.

SortCaseInsensitive As Long

To be documented soon...

Standalone As String

Should be set to "yes" or "no". This is the standalone attribute in the XML declaration. If not present, then this property returns an empty string. This property can be set from any node in the XML document and when set, causes the standalone property to be added to the XML declaration.

Tag As String

The string that is the tag.

TreeId As Long (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 nodes (i.e. Chilkat XML objects) belong to the same tree.

Version As String (read-only)

The version of this component, such as "1.0"

Methods

AddAttribute(name As String, value As String)

Adds an attribute to the node.

AddChildTree(tree As AspXml)

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

AppendToContent(str As String)

Appends character data to the Content property.

BEncodeContent(charset As String, content As Variant)

This sets the node's content with 8-bit 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.

ChildContentMatches(tag As String, pattern As String, caseSensitive As Long) As Long

Returns 1 (true) if the child with the specified tag has content that matches the wildcarded pattern. The "*" characters matches 0 or more of any character. "caseSensitive" should be set to 1 for case-sensitive matching, or 0 for case-insensitive matching.

Clear()

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

CompressNode()

Compresses and Base64 encodes the Content. The Content may be decoded and decompressed by calling DecompressNode.

CompressSubtree()

Compresses the Content and entire subtree under the calling node, and replaces the Content/subtree with the compressed and base64-encoded data which can be later expanded by calling DecompressSubtree.

ContentMatches(pattern As String, caseSensitive As Long) As Long

Returns 1 (true) if the content matches the wildcarded pattern. The "*" characters matches 0 or more of any character. "caseSensitive" should be set to 1 for case-sensitive matching, or 0 for case-insensitive matching.

DecodeContent() As Variant

Decodes a Q or B-encoded content string and returns the byte data in a Variant (byte array). See BEncodeContent and QEncodeContent.

Returns a zero-length byte array (as a Variant) on failure

DecodeEntities(str As String) As String

To be documented soon...

DecompressNode() As Long

Decodes and decompresses the Content that was previously compressed by calling CompressNode.

DecompressSubtree() As Long

Decodes, decompresses, and recreates the content and subtree that was compressed by calling CompressSubtree.

DecryptNode(password As String) As Long

Decodes and decrypts the Content of the calling node, which was originally encrypted by calling EncryptNode. The password must match the password provided during encryption, or you will receive gobbly-gook.

EncryptNode(password As String)

Encrypts and base64 encodes the Content of the calling node. The encryption uses 128-bit AES (Rijndael) algorithm (Cipher-Block Chaining mode).

ExtractChildByIndex(index As Long) As AspXml

Removes and returns a child node. The first child is at index 0.

ExtractChildByName(tag As String, attrName As String, attrValue As String) As AspXml

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

FindChild(tag As String) As AspXml

Returns the first child having a specified tag, or Nothing if no matching child is found.

FindChild2(tag As String) As Long

Updates the calling object to reference the first child having the specified tag. If successful, a value of 1 is returned. Otherwise 0 is returned.

FindNextRecord(tag As String, contentPattern As String) As AspXml

First checks to see if the calling node has a child with a specified tag that matches the wildcarded pattern. If so, it returns itself. If not, it iterates over the caller's subsequent siblings until it finds a node having a child that matches the content.

FindOrAddNewChild(tag As String) As AspXml

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

FirstChild() As AspXml

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

FirstChild2() As Long

Same as FirstChild, except the calling object is updated to reference the first child instead of creating and returning a new object. Returns 1 if updated, returns 0 if there are no children. This method can be used (instead of FirstChild) to help minimize the number of objects created and destroyed in your program.

GetAttrValue(name As String) As String

Returns the value of an attribute. If the attribute is not present, NULL is returned.

Returns a null on failure

GetAttributeName(index As Long) As String

Returns the name of the an attribute. The first attribute is at index 0. The number of attributes is found in the NumAttributes property.

Returns a null on failure

GetAttributeValue(index As Long) As String

Returns the value of the an attribute. The first attribute is at index 0. The number of attributes is found in the NumAttributes property.

Returns a null on failure

GetBinaryContent(unzipFlag As Long, decryptFlag As Long, password As String) As Variant

Retrieves binary content that was previously encoded using SetBinaryContent. The parameters must match those used when setting the content. If zipFlag is 1, the content is unzipped. If encryptFlag is 1, the content is decrypted using the password parameter. (Encryption is 128-bit AES strong encryption.)

Returns a zero-length byte array (as a Variant) on failure

GetChild(index As Long) As AspXml

Returns a child by index. The first child is at index 0. The number of children can be found in the NumChildren property.

GetChild2(index As Long) As Long

Same as GetChild, except the calling object is updated to reference the child instead of creating and returning a new object. Returns 1 if updated, returns 0 if there is no child at the index.This method can be used (instead of GetChild) to help minimize the number of objects created and destroyed in your program.

GetChildContent(tag As String) As String

Returns the Content property of the child having tagName.

Returns a null on failure

GetChildWithTag(tag As String) As AspXml

Returns the child having a tag equal to tagName.

GetNthChildWithTag(tag As String, n As Long) As AspXml

Returns the Nth child having a tag equal to tagName. (Use NumChildrenHavingTag to find the number of children having a given tag.) Indexing begins at 0.

GetParent() As AspXml

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

GetParent2() As Long

Same as GetParent, except the calling object is updated to reference the parent instead of creating and returning a new object. Returns 1 if updated, returns 0 if there is no parent. This method can be used (instead of GetParent) to help minimize the number of objects created and destroyed in your program.

GetRoot() As AspXml

Returns the root node of the tree.

GetRoot2()

Same as GetRoot, except the calling object is updated to reference the tree root instead of creating and returning a new object. This method can be used (instead of GetRoot) to help minimize the number of objects created and destroyed in your program.

GetXml() As String

Generates XML that represents the tree or subtree rooted at this node.

Returns a null on failure

HasAttrWithValue(name As String, value As String) As Long

Returns 1 if this node has an attribute with the given name and value, otherwise returns 0.

HttpGet(url As String) As AspXml

To be documented soon...

HttpPost(url As String) As AspXml

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

LastChild() As AspXml

Returns the last child. A node's children can be enumerated by calling LastChild and then repeatedly calling PreviousSibling, until a NULL is returned.

LastChild2() As Long

Same as LastChild, except an existing object is used and set to reference the internal document node instead of creating and returning a new object. Returns 1 if updated, returns 0 if there are no children. This method can be used (instead of LastChild) to help minimize the number of objects created and destroyed in your program.

LoadRequest()

Loads the XML document passed via XMLHTTP in the ASP Request object.

LoadXml(xmlData As String) As Long

Loads XML from a String and creates a tree with this node at the root. Return 1 if the Xml was successfully parsed and loaded. Returns 0 for failure.

LoadXmlFile(fileName As String) As Long

Loads XML from a file, and creates a tree with this node at the root. Return 1 if the Xml was successfully parsed and loaded. Returns 0 for failure.

LoadXmlV(xmlData As Variant) As Long

Loads XML from a Variant and creates a tree with this node at the root. Return 1 if the Xml was successfully parsed and loaded. Returns 0 for failure.

NewChild(tag As String, content As String) As AspXml

Creates a new child having tag and content. The new child is created even if a child with a tag equal to tagName already exists. (Use FindOrAddNewChild to prevent creating children having the same tags.)

NewChild2(tag As String, content As String)

Same as NewChild except it doesn't return the child that is created.

NextSibling() As AspXml

Returns this node's next sibling.

NextSibling2() As Long

Same as NextSibling, except the calling object is updated to reference the next sibling instead of creating and returning a new object. Returns 1 if updated, returns 0 if there are no more siblings. This method can be used (instead of NextSibling) to help minimize the number of objects created and destroyed in your program.

NumChildrenHavingTag(tag As String) As Long

Returns the number of children having a tag equal to tagName.

PreviousSibling() As AspXml

Returns the node's previous sibling.

PreviousSibling2() As Long

Same as PreviousSibling, except the calling object is updated to reference the previous sibling instead of creating and returning a new object. Returns 1 if updated, returns 0 if there are no more siblings. This method can be used (instead of PreviousSibling) to help minimize the number of objects created and destroyed in your program.

QEncodeContent(charset As String, content As Variant)

This sets the node's content with 8-bit 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.

RemoveAllAttributes()

Removes all attributes from the node.

RemoveAttribute(name As String)

Removes all atributes named attrName from the node.

RemoveFromTree()

Removes this node and its subtree from its tree and makes it a root of a new tree.

SaveLastError(filename As String) As Long

Saves the last error information to an XML formatted file.

SaveXml(fileName As String) As Long

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

SearchAllForContent(after As AspXml, contentPattern As String) As AspXml

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

SearchForAttribute(after As AspXml, tag As String, attr As String, valuePattern As String) As AspXml

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

SearchForContent(after As AspXml, tag As String, contentPattern As String) As AspXml

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

SearchForTag(after As AspXml, tag As String) As AspXml

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

SetBinaryContent(zipFlag As Long, encryptFlag As Long, password As String, content As Variant)

Sets the node's content with binary data. The binary data is taken, Zip compressed if zipFlag is 1, encrypted using 128-bit AES encryption if encryptFlag is 1, and Base64-encoded. The password parameter is only used if encryptFlag is 1. Use GetBinaryContent with the same parameter values to retrieve the binary data from the node.

SortByAttribute(attrName As String, ascending As Long)

Sorts the children of the calling node by the an attribute. The ascending parameter can be 1 or 0. (0 = descending order).

SortByContent(ascending As Long)

Sorts the children of the calling node by the value of each child's content. The ascending parameter can be 1 or 0. (0 = descending order).

SortByTag(ascending As Long)

Sorts the children of the calling node by each child's tag. The ascending parameter can be 1 or 0. (0 = descending order).

SortRecordsByAttribute(sortTag As String, attrName As String, ascending As Long)

Sorts the children of the calling node by and attribute in the grandchild nodes having the sortTag. As an example, imagine that the children of the calling node are contact records, each of which has child nodes for name, address, city, phone, etc. The contact records could be sorted by an attribute on one of the contact child nodes.

SortRecordsByContent(sortTag As String, ascending As Long)

Sorts the children of the calling node by content in the grandchild nodes having the sortTag. As an example, imagine that the children of the calling node are contact records, each of which has child nodes for name, address, city, phone, etc. The contact records could be sorted by these values.

SwapNode(node As AspXml)

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

SwapTree(tree As AspXml)

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

UpdateAttribute(name As String, value As String)

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

UpdateChildContent(tag As String, value As String)

Replaces the content of the child with the specified tag.