title: How to unit test an xml file?
body: <p>I have an XSD schema already for the following xml file </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;note&gt;
   &lt;to&gt; &lt;/to&gt;
   &lt;from&gt; &lt;/from&gt;
   &lt;datetime&gt;  &lt;/datetime&gt;
   &lt;heading&gt; &lt;/heading&gt;
   &lt;body&gt; &lt;/body&gt;
  &lt;/note&gt;
  </code></pre>
  
  <p>I implemented a NoteGnerator to generate xml files based on the schema. The xml files must have to generated regarding some templates/specifications, such as:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;note&gt;
   &lt;to&gt; Lucy &lt;/to&gt;
   &lt;from&gt; Lily &lt;/from&gt;
   &lt;datetime&gt; --date--time-- &lt;/datetime&gt;
   &lt;heading&gt; reminder &lt;/heading&gt;
   &lt;body&gt; do not forget my pen &lt;/body&gt;
  &lt;/note&gt;
  </code></pre>
  
  <p>Another template/specification would be like: </p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;note&gt;
   &lt;to&gt; Lily &lt;/to&gt;
   &lt;from&gt; Lucy &lt;/from&gt;
   &lt;datetime&gt; --date--time-- &lt;/datetime&gt;
   &lt;heading&gt; reply &lt;/heading&gt;
   &lt;body&gt; no problem &lt;/body&gt;
  &lt;/note&gt;
  </code></pre>
  
  <p>, where <code>&lt;datetime&gt;</code> is a dynamic value when the xml is generated (so this value cannot be predetermined). Based on the XSD scheme and these two XML specifications, I can easily generate XML messages. </p>
  
  <p>How can I unit test the generated XML files? </p>
  
  <p>Do I need to validate the generated XML files again the schema? Or I need to use some diff tool to compare the generated xml files and the template? Because the datetime is dynamic, it is different each time when an xml file is generated, so how to compare them with the template? Or I need to deserialise xml to c# object and then test the c# object ?  </p>