Question: I have a .NET webforms application that consumes data from a WCF/REST web service. Most of the time, we use shared classes to pass data back and forth, and that works well. 

However, occasionally we need to display this data in a Datagrid or similar .NET control, and the most convenient way to do this is via a Dataset. I know we can read XML into a dataset using the Dataset.ReadXML(myXML, XmlReadMode.InferTypedSchema) method, and that's been working OK.

Occasionally, though, the InferTypedSchema infers the wrong datatype. For example, it'll decide that a zip code is an integer, not a string.

What are my options? I know I can manually define the dataset schema, but I'd like to avoid that if possible. The web service automatically generates an .xsd (ie, the autogenerated response/schema URL) - is there any way to tell Dataset.ReadXML to use that? Or is there a better way?

Answer: 
I know you can feed your DataSet not just with data but also with schema, something like 

```
dataSet.ReadXmlSchema(new System.IO.StreamReader("schema.xsd"));

```

so if you have the xsd should be fine.
If you know your XSD ahead of time, you can generate a class file from that and then tweak it to ensure you have the right data types (strings for zip code).

[XML Schema Definition Tool (Xsd.exe)](http://msdn.microsoft.com/en-us/library/x6c1kb0s%28v=vs.100%29.aspx)

Once your create your class file, you can use [XmlSerializer.Deserialize](http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.deserialize.aspx) to convert your XML to a class.