I’m trying to copy some text to xml file.
The problem is that all special characters are converted to symbols..
I googled and tested tons of codes but no help so far
I would like to copy a text file that contains the following line
<data path="Procédures de support/Achat" name="Gestion dös achats et dés magasins" type="Main Process" />
however if i use encoding to text file, it works, but if i want to create xml then it doesn’t
Here is my code:
string tempFile = Path.GetTempFileName();
using (var sr = new StreamReader(filePath,Encoding.Default)) // I also tested Encoding.UTF8
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.Default;
using (XmlWriter writer = XmlWriter.Create(fileOutput,settings))
{
writer.WriteStartDocument(false);
writer.WriteStartElement(startRoot);
string line;
while ((line = sr.ReadLine()) != null)
{
writer.WriteRaw(line);
}
writer.WriteEndElement();
writer.WriteEndDocument();
}
}
Any idea?
Somehow it worked when i changed the encoding to