Skip to content

Instantly share code, notes, and snippets.

@ChrisTowles
Created July 6, 2016 12:07
Show Gist options
  • Save ChrisTowles/7411658c5a3b9fdb6d111b0902bfb815 to your computer and use it in GitHub Desktop.
Save ChrisTowles/7411658c5a3b9fdb6d111b0902bfb815 to your computer and use it in GitHub Desktop.
Note to self on the C# Xsd to xml.
Notes for self on XSD to XML
http://stackoverflow.com/questions/6530424/generating-xml-file-using-xsd-file
Open "Developer Command Prompt" and Run the following commands to update the CS file.
d:
cd "D:\Code\TFS\.....\XSD Template"
xsd.exe /classes /namespace:Amazon.Services.ViewModels.Xsd OrderFulfillment.xsd
-----------------------------------------------------------------------------------------------
var data1 = new ViewModels.Xsd.OrderFulfillment()
{
FulfillmentDate = DateTime.Now,
FulfillmentData = new ViewModels.Xsd.OrderFulfillmentFulfillmentData()
{
ShipperTrackingNumber = "123"
}
};
var data2 = new ViewModels.Xsd.OrderFulfillment()
{
FulfillmentDate = DateTime.Now,
FulfillmentData = new ViewModels.Xsd.OrderFulfillmentFulfillmentData()
{
ShipperTrackingNumber = "ABC"
}
};
var serializer = new XmlSerializer(typeof(OrderFulfillment[]));
var ms = new MemoryStream();
serializer.Serialize(ms, new OrderFulfillment[] { data1, data2 });
var output = System.Text.Encoding.UTF8.GetString(ms.ToArray());
output.DebugWriteAsFormatedJson();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment