I have a new problem.
First, thank you for all replies and help, I really appreciate!
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.
My program that process the data use this 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 => new DataColumn(fieldName.Value))
.ToArray();
var rows = doc.Descendants("ROW")
.Select(row => columns.Select(col => (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;
So, when I try to read the file I can't read because do not open the file.
I have two options to read properly:
Option 1: Before open in my program, I need change <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
TO
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>
But this is illegal.
Or I need change the codes like this foto to other without accents (that give too much work to do): Image removing accents
So, why to process the text on C# with ISO-8859-1 (read the xml accents) without change the encoding type on XML file?
Thank you
PS: I look in suggested threads but don't finish a problem like mine.
Thanks
I changed encoding to 1252 and everything works.