Parses an XML string into a .NET object.
This method requires that you provide either .NET type object, or a fully qualified type name (namespace.classname or fully qualified GAC name).
o.FromXml(lcJson,lvDotnetType)
Parameters
lcJson
Xml String. Should be in same format as data returned from ToXml()
lvDotnetType
The type of the object to be deserialized into. Accepts a .NET Type object (use GetType or GetTypeFromName) or a fully qualified class name (Namespace.Class)
Remarks
XML must be in the same format as what ToXml() creates.
<?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:24:26</Entered> <Number>100.21</Number> <Address> <Street>32 Kaiea</Street> <City>Paia</City> </Address> </TestCustomer>
The XML header is not required. If types are simple and well known the namespaces may also not required.
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
See also:
Class wwDotNetBridge | wwDotNetBridge::ToXml | wwDotNetBridge::FromJson | wwDotNetBridge::ToJson© West Wind Technologies, 2023 • Updated: 06/07/17
Comment or report problem with topic