Class wwXML (High Level Methods)

The wwXML class provides both high level and low level methods. The high level methods create fully self-contained XML output documents and can import cursors and classes using this format by re-creating the object and cursor structures on the client end.

The low level methods allow for creating and importing individual pieces of the XML documents.

Note
XML is great for transferring data between applications and even intra application. But please realize that XML has inherent limations transporting some data such as binary content. Ctrl characters and CHR(0) are not allowed and will fail on imports. While XML supports encoding at the node level this cannot be efficiently done for a generic utility such as wwXML.

Class Members

MemberDescription

AddComLineBreak

Adds a linebreak at the end of the node content followed by optional indentation on the next line. Use this if you add nodes to a document and you want to maintain formatting.

o.AddComLineBreak(loNode,lnIndent)

AddDomAttribute

Creates or modifies an attribute on an XMLDOM node.

o.AddDomAttribute(loNode,lcName,lcValue,lcNameSpace)

AddDomNode

Adds a new child node to an existing XMLDOM Node. The new new node is inserted as a child node.

o.AddDomNode(loNode,lcName,lcValue,lcNameSpace)

AddElement

This method can be used to easily create fully encoded XML element strings. The method returns a string for adding an element such as:

o.AddElement(lcTag, lvValue, lnIndent)

ADOtoXML

This method create standard format XML from an ADO recordset. The XML format is identical to that of CursorToXML.

o.ADOtoXML(loRS, lcName, lcRowName, lnIndent, llNoHeader)

ADOXMLToCursor

Takes an ADO created XML recordset saved with rs.Save(<filename>,1) and converts it into a VFP cursor. This operation can be slow due to pure XMLDOM usage to parse the XML.

o.ADOXMLToCursor(lcXML,lcCursor)

CreateErrorXML

This method creates an error XML fragment. The fragment is not a complete document as it lacks the XML header, but rather is meant as a fragment that can be embedded into a full XML document.

o.CreateErrorXML(lcErrorMsg, lnError, lnIndent)

CursorToADOXML

This method exports XML in the ADO compatible XML format. This format is very specific to ADO and although a valid XML structure is not a well designed document and unlikely to be used anywhere else. The output is the equivalent of doing rs.save('filename',1) from ADO.

o.CursorToADOXML()

CursorToRS

This method converts the currently open cursor to an ADO recordset.

o.CursorToRS()

cursortoxml

This high level method creates a full XML document that exports a VFP cursor to an XML document. If you export the file with the nCreateDataStructure flag set to 1 the file will contain a Schema or 2 to contain a DTD that describes the data structure of the table.

o.cursortoxml(lcName, lcRowName, lnIndent, llNoHeader)

DataSetXMLToCursor

Imports data from an XML Dataset into a Fox cursor. As of now the cursor must be pre-created and you must specify which cursor you want to import from the dataset if multiple cursors are contained within it.

o.DataSetXMLToCursor(lvXML,lcAlias, lcDataSetTable)

EncodeXML

Please use the wwxml::nEncoding property instead...

o.EncodeXML(lcXML)

FoxValueToXmlValue

This method looks a the type of the value passed and properly encodes it to XML element syntax. This method only works with FoxPro simple types and single values like strings, bool, numeric, date, binary etc.

o.FoxValueToXmlValue(lvValue)

GetObjVar

Retrieves an element value from a tag expression in an XML document.

o.GetObjVar(lcItem,lcXMLDoc)

Load

Loads an XMLDOM document based on a file or url with error checking.

o.Load(lcUrl, llAsync, llPreserveWhiteSpace)

LoadUrl

Retrieves HTTP using a standard URL into a string. Use this method to download XML from a server quickly and easily without having to instantiate other objects.

o.LoadUrl(lcUrl, lcPostData, lcUsername, lcPassword, lnTimeout)

LoadXML

This method loads an XML document into a Microsoft XMLDom object. The method returns an object reference to the XML object or NULL in the event of failure.

o.LoadXML(vXML)

ObjectToXML

This high level method converts a live object reference to XML. All variables are converted to text and stored.

o.ObjectToXml(loObject, lcName, lnIndent, llNoHeader)

SQLCursorToXML

This method allows you to directly query an ODBC/OleDB data source and return XML for a query or stored procedure result. The data is returned as an XML string in standard format.

o.SQLCursorToXML(lcSQL, lcConnectString, lcName, lcRowName, lnIndent, llNoHeader)

xmltocursor

This high level method takes an XML file created with CursorToXML and converts it back into a cursor. The method can create a cursor automatically, or use an input file you pass in (via a passed open alias name). In order to create the file a DTD like the one exported by CursorToXML must be present in order to provide the Type, Size and Precision attributes required to create the cursor.

o.xmltocursor(lvXML,lcAlias)

XMLToObject

High level method that imports XML into an object. The method can create the object or use an existing object to retrieve the object data. You can optionally pass in an existing object reference and the object will be updated from the XML data matching values of the matching element nodes by property name.

o.XMLToObject(lvXML, loObject, llParseCaseInsensitive)

XmlTypeToFoxType

Converts an XML type to a FoxPro type.

o.XmlTypeToFoxType(lcXmlType)

XMLValueToFoxValue

Converts an XML value into a FoxPro value based on an XML type you specify.

o.XMLValueToFoxValue(lcXMLValue,lcXMLType)

XPathXmlValueToFoxValue

Works like XMLValueToFoxValue except that rather than accepting a string parameter it takes an XPATH expression and rootnode to retrieve a value from an XML document and translate it directly.

o.XPathXmlValueToFoxValue(loRootNode, lcXPath, lcType, @lvStore)

bSkipEmptyElements

If a string element value is 'empty' no value is written in the various XML generation routines.

cBody

Internal buffer that is used to hold XML text. If a document is to be parsed (simple) body will hold the full document including the header.

cDocRootName

This property controls the top level XML tag (xDocRoot) in the example below.

cErrorMsg

If an error occurs this property holds an error messages. Errors can be captured by checking return values of the various methods.

cPropertyExclusionList

List of properties that are not included in the XML document when creating XML from an object with ObjectToXML. This property is preset to strip out most VFP properties used for Custom objects. You can add to this property to filter out additional properties. Lower case values separated by commas.

cSchemaName

Name of the a schema that gets generated when an embedded schema is created.

cSchemaUrl

Links in an external or internal schema. Use #SchemaName for internal schemas and a fully qualified or relative URL for external schemas.

cXMLHeader

The default XML document header. By default this is just the plain XML header without DTD. Used only when creating a document - not set when writing. You may add additional headers to the default or overwrite it .

lRecurseObjects

Allows to recurse child objects hierarchically. When .T. any object member willl be parsed and embedded hierarchically in the XML document.

lStripTypePrefix

When this value is set to True the first letter is stripped from all property names for cleaning up the XML tag names. So properties like cName are turned into Name and lIsSafe turns into IsSafe.

lUseFoxTypes

By default all types are generated using XML types which can be converted to Fox types and back. If you use Fox on both ends of the connection exclusively you can set this flag to .T. to allow the use of native Fox types, which results in better parsing performance.

nCreateDataStructure

By default wwXML creates XML output that does not contain data or object structure information. The data structure information includes type information that allows objects and cursors to be re-created on the client side of the XML connection. When this value is .T. the export methods create a DTD.

nEncoding

Determines how generated XML documents are encoded. By default no encoding occurs (0).

Requirements

Assembly: wwXml.prg

© West Wind Technologies, 2024 • Updated: 11/08/18
Comment or report problem with topic