title: Trying to write to an existing XML file for C#
body: <p>Thank you very much in advance</p>
  
  <p>This is the original XML File</p>
  
  <pre><code>&lt;my:Incident&gt;
         &lt;my:Category&gt;This is for Category&lt;/my:Category&gt;
                &lt;my:Status&gt;`Status is Close`&lt;/my:Status&gt;
         &lt;my:Description&gt;`This is the description part&lt;/my:Description&gt;
  &lt;/my:Incident&gt;
  </code></pre>
  
  <p>and I would like to add other fields under <code>my:Incident</code> </p>
  
  <p>This is an example of it:</p>
  
  <pre><code>&lt;my:Incident&gt;
         &lt;my:Category&gt;This is for Category&lt;/my:Category&gt;
                &lt;my:Status&gt;`Status is Close`&lt;/my:Status&gt;
         &lt;my:SummaryDescription&gt;This is the summary&lt;/my:SummaryDescription&gt;
         &lt;my:Description&gt;`This is the description part&lt;/my:Description&gt;
  &lt;/my:Incident&gt;
  </code></pre>
  
  <p>I tried to implemented but I got this error message:</p>
  
  <blockquote>
    <p>The ':' character, hexadecimal value 0x3A, cannot be included in a name.</p>
  </blockquote>
  
  <pre><code>public void writerXMLTest(string fileName)
          {
  
              if (!File.Exists(fileName))
              {
                  XmlTextWriter writer = new XmlTextWriter(fileName, null);
                  writer.WriteStartElement("my:Incident");
                  writer.WriteEndElement();
                  writer.Close();
              }
  
              XDocument doc = XDocument.Load(fileName);
              XElement demoNode = new XElement("my:Incident");
              demoNode.Add(new XElement("my:SummaryDescription", "Test Test"));
  
  
              Console.WriteLine("I write it!!!!!"); 
          }
  </code></pre>
  
  <p>I would appreciate if anyone can guide me where I did wrong in my code.</p>
  
  <hr>
  
  <p>I modified the code a little. But now I'm not able to write it to the existing XML File</p>
  
  <p>This is my code: </p>
  
  <pre><code>public void writerXMLTest(string fileName)
          {
  
              if (!File.Exists(fileName))
              {
                  XmlTextWriter writer = new XmlTextWriter(fileName, null);
                  writer.WriteStartElement("Incident", "my");
                  writer.WriteEndElement();
                  writer.Close();
              }
  
              XDocument doc = XDocument.Load(fileName);
              XElement demoNode = new XElement("SummaryDescription", "Test Test");
  
  
              Console.WriteLine("I write it!!!!!"); 
          }
  </code></pre>