Wednesday 8 May 2013

Validating the XML file using XSD in C#


I was a novice in the XML world. I just completed my project using the XML. Though I completed the project, I received a bug. Though it was due to human involvement where the name of XML  node was changed.

I thought of handling this error. For this, I searched on Internet and found that the way to validate the XML is to use XML schema file. A read a bit about and found that we can validate any type of XML document using it. There is very nice and simple documentation is available at “http://www.w3schools.com/schema/default.asp”. 

For creating the XML schema (.xsd) file for a XML file, you can use http://www.flame-ware.com/products/xml-2-xsd/ where you need to provide the source XML file. 

Below is the code snippet that I had used while for validating the XML document. 
Xml Validation code snippt

If you find the blog helpful, please provide us with your feedback so that we can make more useful. 






About Me

Don't be scared to do something simple and don't be afraid to do something difficult, but do it for the right reasons