I want users to be able to export data as an XML file. Of course I want them to be able to later on import that same XML file however they always could change it or it could be a different XML file.
So I want to validate the XML file to check if it is in the format that I expect. So I guess I would need something like a schema to check just that it has to be through code.
So if I expect
<Root>
<Something>
<SomethingElse> </SomethingElse>
</Something>
</Root>
I don't want some other format to be in the file other then the one I expect.
Also how would I validate fields? Like say I require that there must be some text in between tags. If it is blank the file is not valid.
So how could I do this?
Edit
I decided to use XML serialization so I know it will through an exception if it is the wrong format and ignore stuff that does not work. However I am not sure should I just go through it and C# to validate each of the records or should I try to make an xml schema to do it.
If I would want to do it through an xml schema with xml serialization how would that work? Like Do I first do something like I seen in the responses then de serialize it? Or how would I do it?