In the previous article, I explained how to use an XSD schema to validate XML data documents. This one is a bit deeper: Can the XSD schema be embedded directly in the program as a resource? This way, we can better protect this file.
Preparation: For testing, create a consoleapplication
1. First of all, our sample data is relatively simple. Please Save as Order.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<Order>
<OrderID>10248</OrderID>
< orderdate>2009-01-01</orderdate>
<Items>
<OrderItem>
<itemnumber>1</ itemnumber>
<ProductID>2</ProductID>
<Quantity>12.00</Quantity>
< unitprice>25.6</unitprice>
</OrderItem>
<OrderItem>
<itemnumber>1 </ItemNumber>
<ProductID>2</ProductID>
<Quantity>12.00</Quantity>
<UnitPrice>25.6</UnitPrice>
</OrderItem>
<OrderItem>
< itemnumber>1</itemnumber>
<ProductID>2</ProductID>
<quantity>12.00</ quantity>
<UnitPrice>25.6</UnitPrice>
</OrderItem>
</Items>
</Order>