I've used XSD2Code to create a set of C# classes representing an XML document I'm currently retrieving from a web service call.
The returned object of the web service call is of type XMLNode.
I want to create an object from the generated classes and then populate it from the XMLNode.
The outter most class that seems to be have been generated is NewDataSet.
I'm a little stuck as to how to create/populate that object. Do I need to use Deserialization?
The way I ended up resolving this was as follows.
I used the project Linq to XSD Project: http://linqtoxsd.codeplex.com/
Using the XSD I created a new set of C# Classes From the command prompt
C:\Linq2XSD\linqtoxsd.2.0.2.56002-bin>LinqToXsd.exe vehicle.xsd
[Microsoft (R) .NET Framework, Version v4.0.30319]
Generated vehicle.cs...
I then imported this C# file into my code.
I had to add a reference to the Xml.Scheme.Linq library I could then create a populated set of objects:
VehiclesData vehicleData = VehiclesData.Parse(vehiclesXMLNode.OuterXml);
and use Linq to access typed XML as follows:
string vehicleColour = vehicleData.DataArea.Vehicles.Vehicle.ColourCurrent;
and so forth!