Switch from current encoding to specified encoding not supported when opening XML in browser
<p>I am trying to open an xml file in browser and I get the following error:</p>

<p>Switch from current encoding to specified encoding not supported. Error processing resource</p>



<p>Now I am generating this XML using C# by the code below. My XML has latin characters so I want to have encoding as ISO-8859-1 and not utf-16. But each time my xml generate, it take encoding as utf-16 and not ISO-8859-1. I would like to know what is the cause and resolution. </p>

<p>Note: I only need ISO-8859-1 and not utf-8 or utf-16 as the XML is getting generated properly if the encode is ISO-8859-1.</p>

<p>C# code:</p>

<pre><code>var doc = new XDocument(new XDeclaration("1.0", "iso-8859-1", "yes"),new XElement("webapp", new XAttribute("name", webApp.Name), new XAttribute("id", webApp.Id), Myinformation());
  var wr= new StringWriter();
            doc.Save(wr);
            return wr.ToString();
</code></pre>