XmlDoc Class

GPL includes an XmlDoc class. The objects of this class operate on the top-level of a DOM tree (which contains an entire XML document). The XmlDoc methods deal with the document as a whole and, except for a method that allocates new nodes, these methods do not operate on specific nodes in the DOM tree. For example, this class includes the method for converting an XML text file into a DOM tree and a method for the reverse operation.

There is one and only one XmlDoc object for each separate XML document that is represented as a DOM tree. An XML DOM tree cannot exist without an XmlDoc object. When the last reference to an XmlDoc object is freed, the entire DOM tree is also freed. Any XmlNode objects that refer to nodes in the tree are marked as invalid.

The XmlDoc class interface is summarized in Table 19-44.  Each of these properties and methods is described in detail in the GPL Dictionary contained in the Software Reference section of the PreciseFlex Library.

Table 19-44: XmlDoc Class Interface 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.