title: Generate XML file and read it back
body: <p>I'm looking for a good clean way of writing XML to a configuration file and being able to read it back into the Application.</p>
  
  <p>I have an Array of properties that each contain a list of fields.</p>
  
  <p>For example a list of Camera Properties.</p>
  
  <p>Each property has 
  Name, Value, Category, Type, Description.</p>
  
  <p>I would like my XML Config to look like this </p>
  
  <pre><code>&lt;Camera_Properties&gt;
      &lt;Property Name="Height" Value="40" Category="Dimensions" Type="Int" Description="The height of the box"&gt;
      &lt;Property Name="Width" Value="40" Category="Dimensions" Type="Int" Description="The width of the box"&gt;
  &lt;/Camera_Properties&gt;
  </code></pre>
  
  <p>Firstly is this possible, or practical?</p>
  
  <p>I Can't seem to find a way of writing this and more impotently being able to parse it in such a way that it can be pulled apart so I could read the Config file and as each element is found call code like this</p>
  
  <p>SetProperty(xmlelement.name, xmlelement.Value, xmlelement.Type); </p>
  
  <p>So far i have managed to get this output</p>
  
  <pre><code>&lt;Camera_Properties&gt;
      &lt;Property&gt;
          &lt;Name&gt; Height&lt;/Name&gt;
          &lt;Value&gt; 100 &lt;/Value&gt;
          &lt;Category&gt; Dimensions &lt;/Category&gt;
          &lt;Type&gt; Int &lt;/Type&gt;
          &lt;Description&gt; Height of the box &lt;/Description&gt;
      &lt;/Property&gt;
   &lt;/Camera_Properties&gt;
  </code></pre>
  
  <p>But this is not practical for how i need to use the configuration file.</p>
  
  <p>I have used System.Xml.XmlDocument to get this far. If there is a better alternative i would appreciate suggestions.</p>
  
  <p>But as there are hundreds of properties this is too messy and hard to read.</p>
  
  <p>If anyone can help or knows where there may be a relevant example i could use as a guide it would greatly help. </p>
  
  <p>Thanks</p>
  
  <p>EDIT</p>
  
  <p>I would like to loop through and generate an XML file with these properties from an array. The idea is that this file can be used to load in proprieties and set properties as the change each time the hardware is powered off.</p>
  
  <pre><code>public void CreateXML()
  {
     // Setup document and header tags
  
      foreach(Property prop in propertyArray)
      {
         create single element here with prop.Name, Prop.Age etc as attributes
      }
  
      SaveXml(Filename);
  }
  </code></pre>
  
  <p>The SDK i use for the hardware has an Array of parameters so i would prefer to generate the file from this instead of a dataset.</p>