title: C# XmlReader encoding defined as utf-8 but have Iso-8859-1 characters on file
body: <p>I have a new problem.</p>
  
  <p>First, thank you for all replies and help, I really appreciate!</p>
  
  <p>So, my actual problem is: The state release a model of xml file that need be filled and keep the model data with UTF-8 encoding!
  When the people fill the data on software, they use some characters that are in ISO-8859-1 encode type like: Ç Õ Á and generate the file again, continue saved as UTF-8 and use the accents.</p>
  
  <p>My program that process the data use this code:</p>
  
  <pre><code>    XmlReader xmlFile = XmlReader.Create(ofd.FileName, new XmlReaderSettings());
                  ds.ReadXml(xmlFile);
  
                  var doc = XDocument.Load(ofd.FileName);
                  var columns = doc.Descendants("FIELD")
                      .Attributes("attrname")
                      .Select(fieldName =&gt; new DataColumn(fieldName.Value))
                      .ToArray();
  
                  var rows = doc.Descendants("ROW")
                      .Select(row =&gt; columns.Select(col =&gt; (string)row.Attribute(col.ColumnName)).ToArray());
                  var table = new DataTable();
  
                  table.Columns.AddRange(columns);
  
                  foreach (var row in rows)
                  {
                      table.Rows.Add(row);
                  }
                  // Aqui ele mostra os dados das tabelas do arquivo XML exibindo seus dados.
                  dataGridView1.DataSource = table;
  </code></pre>
  
  <p>So, when I try to read the file I can't read because do not open the file.</p>
  
  <p>I have two options to read properly:
  Option 1: Before open in my program, I need change <code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;</code></p>
  
  <p><strong>TO</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?&gt;
  </code></pre>
  
  <p>But this is illegal.</p>
  
  <p>Or I need change the codes like this foto to other without accents (that give too much work to do):
  <a href="http://i.stack.imgur.com/lxIR3.jpg" rel="nofollow">Image removing accents</a></p>
  
  <p>So, why to process the text on C# with ISO-8859-1 (read the xml accents) without change the encoding type on XML file?</p>
  
  <p>Thank you</p>
  
  <p>PS: I look in suggested threads but don't finish a problem like mine.</p>
  
  <p>Thanks</p>