How to encode text writting to xml file using System.Xml.XmlTextWriter.WriteElementString

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am trying to write an xml file using System.Xml.XmlTextWriter. Everything except that characters that are supposed to be convert to a multi-character escape sequence arent. These are characters such as < > & and ". Also characters that have an ascii value greater than 127 (such as the degree symbol) need to be converted to multi-character UTF-8 sequence.
The problem is that although I have told the xml text writer class that I want to create a UTF-8 file:
writer = New XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8)
Calls to:
writer.WriteElementString("Description", mDescription)
Dont write the text stored in mDescription properly in UTF-8. It is frustrating that I cannot find the proper documentation on something so simple.
Can anyone help?
Thank You! - Andy

View the full article
 
Back
Top