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.

Table 19-115: XML Classes Summary

XmlDoc Class Member Type Description

New

Constructor Method

Creates a new document tree with the specified name.

xmldoc_obj.CreateNode

Method

Returns a new XmlNode object for this document with the specified type, and name.

XmlDoc.DecodeEntities

Shared Method

Converts a String containing encoded XML entities into raw text.

xmldoc_obj.
DocumentElement

Method

Returns the XmlNode element that is the root of the document.

XmlDoc.EncodeEntities

Shared Method

Converts special characters in a String to XML entities.

xmldoc_obj.ErrorCode

Get Property

Returns the last parser error code number, or 0 if no error.

XmlDoc.LoadFile

Shared Method

Loads and parses an XML text document from a file and returns the created XmlDoc DOM tree object.

XmlDoc.LoadString

Shared Method

Parses an XML text document from a String and returns the created XmlDoc DOM tree object.

xmldoc_obj.Message

Get Property

Returns the last parser error message, or “” if no error.

xmldoc_obj.SaveFile

Method

Converts a DOM tree document to the XML text format and writes the data to a file.

xmldoc_obj.SaveString

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:

Table 19-116: XmlNode Class Interface

XmlNode Class Member Type Description

xmlnode_obj.AddAttribute

Method

Adds an attribute node as a child of this node.

xmlnode_obj.AddElement

Method

Adds an element node as a child of this node. Includes an optional value.

xmlnode_obj.AddElementNode

Method

Adds an element node as a child of this node. Returns an XmlNode object for the new node. Includes an optional value.

xmlnode_obj.AppendChild

Method

Appends a new child node as the last child of this node. Merges text nodes.

xmlnode_obj.ChildNodeCount

Get Property

Returns the number of children of this node.

xmlnode_obj.Clone

Method

Returns a clone of this node. Optionally recursively clones the subtree under this node.

xmlnode_obj.FirstChild

Method

Returns the first child of this node.

xmlnode_obj.GetAttribute

Method

Returns a String containing the value of the specified attribute that is a child of this node.

xmlnode_obj.GetAttributeNode

Method

Returns the node corresponding to the specified attribute that is a child of this node.

xmlnode_obj.GetElement

Method

Returns a String containing the value of the specified element that is a child of this node.

xmlnode_obj.GetElementNode

Method

Returns the node corresponding to the specified element that is a child of this node.

xmlnode_obj.HasAttribute

Method

Returns True if the specified attribute is a child of this node.

xmlnode_obj.HasChildNodes

Get Property

Returns True if the node has any non-attribute child nodes.

xmlnode_obj.HasElement

Method

Returns True if a specified element is a child of this node.

xmlnode_obj.InsertAfter

Method

Inserts a new node as a child of this node after a referenced child node. Merges text nodes.

xmlnode_obj.InsertBefore

Method

Inserts a new node as a child of this node before a referenced child node. Merges text nodes.

xmlnode_objLastChild

Method

Returns the last child of this node.

xmlnode_obj.Name

Get Property

Returns the node name as a String.

xmlnode_obj.NextSibling

Method

Returns the next sibling of this node.

xmlnode_obj.OwnerDocument

Method

Returns the XmlDoc associated with this node.

xmlnode_obj.ParentNode

Method

Returns the parent of this node.

xmlnode_obj.PreviousSibling

Method

Returns the previous sibling of this node.

xmlnode_obj.RemoveAttribute

Method

Removes a specified attribute from this node's children.

xmlnode_obj.RemoveChild

Method

Removes a child node from the list of children for this node.

xmlnode_obj.RemoveElement

Method

Removes a specified element from this node's children.

xmlnode_obj.ReplaceChild

Method

Replaces an old child node with a new child node.

xmlnode_obj.SetAttribute

Method

Sets the value of an existing specified attribute that is a child of this node.

xmlnode_obj.SetElement

Method

Sets the value of an existing specified element that is a child of this node.

xmlnode_obj.Type

Get Property

Returns the node type as a String.

xmlnode_obj.Value

Get/Set Property

Returns the node value as a String or sets the node value.