Using XmlAdapter to Create and Load Nested XML
An XmlAdapter in VFP 9.0 allows to create and load nested XML.
$SAMPLECODE$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 * Create nested XML using Orders and OrderDetails tables from VFP Northwind DBC CLOSE DATABASES ALL OPEN DATABASE (HOME(2)) + "Northwind\northwind.dbc" * Create XML SELECT 0 USE northwind!OrderDetails SET ORDER TO ORDERID SELECT 0 USE northwind!Orders SET RELATION TO OrderID INTO OrderDetails oXA = CREATEOBJECT("XmlAdapter") * The next setting is required to create nested XML oXA.RespectNesting = .T. oXA.AddTableSchema("Orders") oXA.AddTableSchema("OrderDetails") * Save XML in the current directory oXA.ToXML("Orders.xml",,.T.) * View created XML Modify Command Orders.xml * * Now load created XML back * CLOSE DATABASES ALL * Load XML oXA = CREATEOBJECT("XmlAdapter") oXA.RespectNesting = .T. oXA.LoadXML("Orders.xml",.T.) FOR i=1 TO oXA.Tables.Count oXA.Tables(i).Tocursor() ENDFOR SET
Comments