Hi, I am new to c# language. Can someone please advice how can I go about writing XML data which has to confirm/validate with with a particular schema. So kind of schema aware programming.
Here is more info:
I have the data and a schema. I need to write a xml document that will eventually validate with this schema.
Any code snippet or urls would be helpful.
Your inputs will be much appriciated.
Thanks,
Loading
Amit ChoudharyPosted Feb 16, 2010, 7:58 AM
Well according to your requirements i have found something may help you:
http://support.microsoft.com/kb/318504
http://dotnetslackers.com/Community/blogs/haissam/archive/2008/11/06/validate-xml-against-xsd-xml-schema-using-c.aspx
Hope it helps you.
TigerPosted Feb 16, 2010, 6:37 AM
Its not about reading a xml file and then validating against a schema. It is about writing a brand new xml file (with the data I will fetch from somewhere. say database) and that xml file has to confirm to a xsd schema i.e. xml file structure will come from the schema specified. Let me know if you are still not clear.
I am sure there must be a way to achieve this as I dont want to write each and every element/attribute. I have been looking at linq to xsd but it seems that microsoft has not released it as a product. Correct me if I am wrong.
Now I am looking at xsd.exe utility, which probably can convert xsd into C# classes and I can use those classes in some way to achieve what I want. Please suggest if I am in the correct direction and it will even nice if you could help me with some code snippets or urls. I am just 2 days old in c# and it will be much appriciated.
Amit ChoudharyPosted Feb 16, 2010, 6:35 AM
here is some article on XML schema validations:
http://support.microsoft.com/kb/307379
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=102
Please mark as answer if it helps to some extent.
Lalit MPosted Feb 16, 2010, 6:13 AM
http://csharp-slackers.blogspot.com/2008/09/validate-xml-document-against-schema_18.html
http://support.microsoft.com/kb/307379
http://www.codeguru.com/csharp/csharp/cs_data/xml/article.php/c6737
http://www.csharpfriends.com/articles/getarticle.aspx?articleid=102
http://asp.dotnetheaven.com/howto/doc/Xml/XmlDocumentValidation.aspx
http://www.codeproject.com/KB/cpp/Simple_XML_Validator.aspx