0

I have a string with a XML text and i want to save it like XML. I encoded string (to "utf-8") but when i want to make XML from that - my cyrillic symbols in Value don't displayed right . What i need to do to encode my XML document ?

part of my xml :

 <rev:Code>Мои данные</rev:Code>

my code:

 string send = Encoding.GetEncoding("utf8").GetString(Encoding.GetEncoding("utf-8").GetBytes(send)); 
XmlDocument docsec = new XmlDocument();
 docsec.LoadXml(send);
docsec.Save("C:\\XmlNEW.xml");

Original text :Мои данные

I see it after creating XML :Мои данные

2 Answers 2

0

I worked with russian textfiles before to convert them to rtf and used "Encoding.GetEncoding(1251)" for that purpose.

0

Problem was in Save Method because it use xml encoding, i take my answer from this : Answer

XmlDocument docsec = new XmlDocument();
docsec.LoadXml(send);
using (TextWriter writer = new StreamWriter("C:\XmlNEW.xml", false, Encoding.UTF8))
    docsec.Save(writer);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.