wwDotNetBridge::ToXml

Serializes a .NET object to an XML string.

o.ToXml(loDotnetObject)

Return Value

XML string

Parameters

loDotnetObject
A .NET object reference or simple value like string, number, date, bool etc.

Remarks

Only works on .NET Interop objects or simple values. If you pass in a FoxPro or non-.NET COM object an empty object will be rendered.

Example

loBridge = GetwwDotnetBridge()

*** Create XML
loCust = loBridge.CreateInstance("Westwind.WebConnection.TestCustomer")
loCust.Name = "Rick"
loCust.Company = "Westwind"
loCust.Number = 100.21
loCust.Entered = DATETIME()
loCust.Address.Street = "32 Kaiea Place"
loCust.Address.City = "Paia"

*** Serialize to XML string
lcXml = loBridge.ToXml(loCust)
? lcXml
loCust = null

*** Deserialize back to object
loCust2 = loBridge.FromXml(lcXml,"Westwind.WebConnection.TestCustomer")
? loBridge.cErrorMsg
? loCust2.Company 
? loCust2.Address.City
<?xml version="1.0" encoding="utf-8"?>
<TestCustomer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <Name>Rick</Name>
   <Company>Westwind</Company>
   <Entered>2013-02-03T17:30:22</Entered>
   <Number>100.21</Number>
   <Address>
      <Street>32 Kaiea</Street>
      <City>Paia</City>
   </Address>
</TestCustomer>

See also:

Class wwDotNetBridge

© West Wind Technologies, 1996-2024 • Updated: 05/21/20
Comment or report problem with topic