I have a System.Xml.XmlDocument object and I want to change the xml Encoding from UT16 to UTF8. How do I do it?
I have a System.Xml.XmlDocument object and I want to change the xml Encoding from
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
XmlDocument uses it’s own (DOM-based) internal representation of the XML; the encoding only comes into play when the XML is writen to and stored as text somewhere. You can use the XmlDocument.WriteTo method and provide an
XmlWriterconfigured using anXmlWriterSettingspassed in toXmlWriter.Create. There is an XmlWriterSettings.Encoding property where you can specify UTF8.For example: