XML Classes Summary
The following pages provide detailed information on the classes used to create, parse, and modify XML (eXtensible Markup Language) documents. These classes handle XML text documents by converting them to and from a tree structure that is stored in the controller’s memory. A parsed XML document tree consists of nodes for items in the document, arranged in a tree that reflects how items in the text document are nested. The tree is constructed using a subset of the Document Object Model (DOM) Core Interfaces as described in: http://www.w3.org/TR/REC-DOM-Level-1 and methods similar to those found in Visual Basic.NET.
There are two built-in classes in GPL to handle XML document objects.
XmlDocClass objects operate on the top-level of a DOM tree, which contains an entire XML document. The nodes within the tree contain the data from the document. The XmlDoc methods deal with the document as a whole, for example loading it into memory or saving it to a file. There is one and only one XmlDoc object for each separate XML document, although there can be multiple pointers to this object. An XML DOM tree cannot exist without an XmlDoc object.
XmlNodeClass objects point to individual nodes in a DOM document tree. Its methods support accessing or modifying node data or properties, and adding or removing nodes in the tree structure. These objects point to DOM nodes but do not actually contain the DOM nodes. When an XmlNode object is created or destroyed, the underlying DOM nodes are not affected provided that they are part of a DOM tree. See Table 19-115.
XmlDoc Class Member | Type | Description |
---|---|---|
Constructor Method |
Creates a new document tree with the specified name. |
|
Method |
Returns a new XmlNode object for this document with the specified type, and name. |
|
Shared Method |
Converts a String containing encoded XML entities into raw text. |
|
Method |
Returns the XmlNode element that is the root of the document. |
|
Shared Method |
Converts special characters in a String to XML entities. |
|
Get Property |
Returns the last parser error code number, or 0 if no error. |
|
Shared Method |
Loads and parses an XML text document from a file and returns the created XmlDoc DOM tree object. |
|
Shared Method |
Parses an XML text document from a String and returns the created XmlDoc DOM tree object. |
|
Get Property |
Returns the last parser error message, or “” if no error. |
|
Method |
Converts a DOM tree document to the XML text format and writes the data to a file. |
|
Method |
Converts a DOM tree document to the XML text format and writes the data to a String. |
The XmlNode class interface is summarized in Table 19-116:
XmlNode Class Member | Type | Description |
---|---|---|
Method |
Adds an attribute node as a child of this node. |
|
Method |
Adds an element node as a child of this node. Includes an optional value. |
|
Method |
Adds an element node as a child of this node. Returns an XmlNode object for the new node. Includes an optional value. |
|
Method |
Appends a new child node as the last child of this node. Merges text nodes. |
|
Get Property |
Returns the number of children of this node. |
|
Method |
Returns a clone of this node. Optionally recursively clones the subtree under this node. |
|
Method |
Returns the first child of this node. |
|
Method |
Returns a String containing the value of the specified attribute that is a child of this node. |
|
Method |
Returns the node corresponding to the specified attribute that is a child of this node. |
|
Method |
Returns a String containing the value of the specified element that is a child of this node. |
|
Method |
Returns the node corresponding to the specified element that is a child of this node. |
|
Method |
Returns True if the specified attribute is a child of this node. |
|
Get Property |
Returns True if the node has any non-attribute child nodes. |
|
Method |
Returns True if a specified element is a child of this node. |
|
Method |
Inserts a new node as a child of this node after a referenced child node. Merges text nodes. |
|
Method |
Inserts a new node as a child of this node before a referenced child node. Merges text nodes. |
|
Method |
Returns the last child of this node. |
|
Get Property |
Returns the node name as a String. |
|
Method |
Returns the next sibling of this node. |
|
Method |
Returns the XmlDoc associated with this node. |
|
Method |
Returns the parent of this node. |
|
Method |
Returns the previous sibling of this node. |
|
Method |
Removes a specified attribute from this node's children. |
|
Method |
Removes a child node from the list of children for this node. |
|
Method |
Removes a specified element from this node's children. |
|
Method |
Replaces an old child node with a new child node. |
|
Method |
Sets the value of an existing specified attribute that is a child of this node. |
|
Method |
Sets the value of an existing specified element that is a child of this node. |
|
Get Property |
Returns the node type as a String. |
|
Get/Set Property |
Returns the node value as a String or sets the node value. |