title: Combining XmlSerializer and XmlWriter?
body: <p>In addition to a list of objects I am serializing to an xml file using C#'s XmlSerializer, I would like to store a few more independent elements (mainly strings from textboxes) in the same xml.</p>
  
  <pre><code>    public static void SaveBehaviors(ObservableCollection&lt;Param&gt; listParams)
      {
          XmlSerializer _paramsSerializer = new XmlSerializer(listParams.GetType());
          string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
          path += "\\test.xml";
          using (TextWriter writeFileStream = new StreamWriter(path))
          {
              _paramsSerializer.Serialize(writeFileStream, listParams);
  
              using (XmlWriter writer = XmlWriter.Create(writeFileStream))
              {
                  writer.WriteStartElement("Foo"); //test entry...
                  writer.WriteAttributeString("Bar", "Some &amp; value");
                  writer.WriteElementString("Nested", "data");
                  writer.WriteEndElement();
              }
          }
      }
  </code></pre>
  
  <p>However, deserializing "test.xml" results in an error because of the added element. I suppose writing in the serialized xml file is prohibited and should be avoided?</p>