* wwxml::copyobject LPARAMETER oObject LOCAL loObject, laFields[1], x, lcField, lcType loObject = CREATE(THIS.cObjectClass) lnCount = AMEMBERS(laFields, oObject) FOR x=1 to lnCount lcField = LOWER(laFields[x]) IF AT("," + lcField + ",","'" + THIS.cPropertyExclusionList)>0 LOOP ENDIF lcType = TYPE("loObject."+lcField) IF lcType = "O" loObject.AddProperty(lcField) THIS.CopyObject(EVAL("oObject."+lcField)) ELSE loObject.AddProperty(lcField,EVAL("oObject."+lcField)) ENDIF ENDFOR RETURN loObjectThis version doesn't do arrays, but in my case I don't need that as I'm using this to deal with object array processing in the first place. Adding array support would just require one extra step of checking for the array and then figuring out the dimensions to walk.
o=CREATE("cInvoice") o.Load( 849584) ? o.oData.InvTotal ? o.oCustomer.oData.Company ? o.oLineItems.aRows[1].odata.ItemTotal loXML = CREATE("wwXML") loXML.lRecurseObjects = .t. lcXML = loXML.ObjectToXML(o) ShowXML(lcXML) RELEASE o *** Create new Invoice object and restore from XML o=CREATE("cInvoice") *** Load a blank invoice with empty customer *** and lineitems objects o.Load(0) loXML = CREATE("wwXML") loXML.lRecurseObjects = .t. loXML.XMLToObject(lcXML,o) *** Shows Data restored from XML ? o.oData.InvTotal ? o.oCustomer.oData.Company ? o.oLineItems.aRows[1].odata.ItemTotal