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.

You can also generically import XML as long as the basic structure is followed:


The names of the elements is irrelevant, but the hierarchical document structure (xdoc/objectname/property) is.

If a datastructure DTD is included in the object, the object structure can be created on the fly, but only on flat objects that are not recursed. If ObjectToXML was used to export the object with a DTD the object is reassembled. All properties are rebuilt, but the actual object method interfaces are not available. To import to a complete object you must pass an object reference to this method.

o.XMLToObject(lvXML, loObject, llParseCaseInsensitive)


Either an XML string or an XML DOM object

Optional - an object that is to be populated. If the object exists the structure information is not parsed. A DTD must be present to create an object on the fly. Use lCreateDataStructure when exporting to do so.

Parses the object XML case insensitively which allows wwXML to match VFPs default lower case property names to mixed case properties provided in the XML. Note: Use this only if needed as it is considerably slower to parse as each property is searched out.


This method uses the IE 5 DOM parser.

In order to import from XML the XML must be in a specific format.



*** Create the object
loObject = oXML.XMLToObject(FileToStr("temp.xml"))

*** Use existing object and update it from XML
loObject = CREATE("TestObject")
loObject = oXML.XMLToObject(FileToStr("temp.xml"),loObject)

<?xml version="1.0"?> <!DOCTYPE xdoc [ <!ELEMENT xdoc (wwxml)> <!ELEMENT wwxml (cbody,cdocrootname,cdtd,cerrormsg,cobjectclass,cpropertyexclusionlist,cxmlheader,lcreatedatastructure,lrecurseobjects,lusefoxtypes,lxmlheadersent)> <!ELEMENT cbody (#PCDATA)> <!ATTLIST cbody type CDATA #FIXED "string" > <!ELEMENT cdocrootname (#PCDATA)> <!ATTLIST cdocrootname type CDATA #FIXED "string" > <!ELEMENT cdtd (#PCDATA)> <!ATTLIST cdtd type CDATA #FIXED "string" > <!ELEMENT cerrormsg (#PCDATA)> <!ATTLIST cerrormsg type CDATA #FIXED "string" > <!ELEMENT cobjectclass (#PCDATA)> <!ATTLIST cobjectclass type CDATA #FIXED "string" > <!ELEMENT cpropertyexclusionlist (#PCDATA)> <!ATTLIST cpropertyexclusionlist type CDATA #FIXED "string" > <!ELEMENT cxmlheader (#PCDATA)> <!ATTLIST cxmlheader type CDATA #FIXED "string" > <!ELEMENT lcreatedatastructure (#PCDATA)> <!ATTLIST lcreatedatastructure type CDATA #FIXED "boolean" > <!ELEMENT lrecurseobjects (#PCDATA)> <!ATTLIST lrecurseobjects type CDATA #FIXED "boolean" > <!ELEMENT lusefoxtypes (#PCDATA)> <!ATTLIST lusefoxtypes type CDATA #FIXED "boolean" > <!ELEMENT lxmlheadersent (#PCDATA)> <!ATTLIST lxmlheadersent type CDATA #FIXED "boolean" > ]> <xdoc> <wwxml> <cbody></cbody> <cdocrootname>xdoc</cdocrootname> <cdtd></cdtd> <cerrormsg></cerrormsg> <cobjectclass>wwLight</cobjectclass> <cpropertyexclusionlist>,classlibrary,baseclass,comment,controlcount,class,name,objects,parent,controls,parentclass,helpcontextid,whatsthishelpid,width,height,top,left,tag,picture,</cpropertyexclusionlist> <cxmlheader><![CDATA[<?xml version="1.0"?> ]]></cxmlheader> <lcreatedatastructure>.T.</lcreatedatastructure> <lrecurseobjects>.F.</lrecurseobjects> <lusefoxtypes>.F.</lusefoxtypes> <lxmlheadersent>.F.</lxmlheadersent> </wwxml> </xdoc>

See also:

Class wwXML (High Level Methods)

© West Wind Technologies, 2023 • Updated: 04/17/04
Comment or report problem with topic