How to replace or remove the spl character in xml
<p>Am creating an xml file using xmlwriter,i thought it works fine but when i try to validate it fails bcoz there is spl character (BOM) appears like below,just gone thru forum seen lot of people adive me to use "SecurityElement.Escape". Am not sure how and where.Some one please guide me to remove this spl charecter from the xml file.</p>

<pre><code>Ã¯Â»Â¿&lt;?xml version="1.0" encoding="utf-8"?&gt;
</code></pre>

<p>if found the code for the above symbol</p>

<p>It look like <code>&amp;#195;&amp;#175;&amp;#194;&amp;#187;&amp;#194;&amp;#191;&amp;#060;</code></p>

<p>My Code</p>

<pre><code>             XmlWriter xmlWrite;
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.OmitXmlDeclaration = true;
                xmlWrite = XmlWriter.Create(@"c:\test.xml",settings);
            xmlWrite.WriteStartElement("metadata");
            xmlWrite.WriteElementString("story", story);
            xmlWrite.Close();
</code></pre>

<p>i can succesfully remove the version but still the spl characters are there . Am stuck now.</p>

<p>Any help  ?</p>

<p>This is the Answer to help me to get rid of the spl char</p>

<pre><code>                    XmlWriter xmlWrite;
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Encoding = new UTF8Encoding(false);//Thanks to DaveE
                    settings.ConformanceLevel = ConformanceLevel.Fragment;
                    settings.OmitXmlDeclaration = true;
                    xmlWrite = XmlWriter.Create(@"c:\test.xml",settings);
</code></pre>

<p>when am append i used "using (TextWriter sw = new StreamWriter(@"c:\test.xml")) to work it out</p>

<pre><code> XmlDocument doc = new XmlDocument();
           doc.Load(@"C:\test.xml");
            XmlNode newChild = doc.CreateNode(XmlNodeType.Element, "image", null);
            var attribute = doc.CreateAttribute("name");
            attribute.Value = nameOnly;
            newChild.Attributes.Append(attribute);
            XmlNode xmlElement = doc.CreateNode(XmlNodeType.Element, "width", null);
            xmlElement.InnerText = widthValue[1].TrimStart();
            newChild.AppendChild(xmlElement);
            using (TextWriter sw = new StreamWriter(@"C:\test.xml")) 
            {
                doc.Save(sw);

            }
</code></pre>
