title: How to validate xml code file though .NET? + How would I do it if I use XML serialization?
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>So if I expect</p>
  
  <pre><code>&lt;Root&gt;
   &lt;Something&gt;
      &lt;SomethingElse&gt; &lt;/SomethingElse&gt;
   &lt;/Something&gt;
  &lt;/Root&gt;
  </code></pre>
  
  <p>I don't want some other format to be in the file other then the one I expect.</p>
  
  <p>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.</p>
  
  <p>So how could I do this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>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.</p>
  
  <p>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?</p>