Question on xml encoding in C#,
-
I have this code snipet in my c# classs that generates a string containg xml data. //build xml data StringWriter xmlStringWriter = null; XmlTextWriter xmlWriter = null; string xmlString = ""; StringBuilder xmlStringBuilder = new StringBuilder(); try { xmlStringWriter = new StringWriter(xmlStringBuilder); xmlWriter = new XmlTextWriter((xmlStringWriter); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(); //start document //populate xml However, the generated xml string contains the header as: Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
-
I have this code snipet in my c# classs that generates a string containg xml data. //build xml data StringWriter xmlStringWriter = null; XmlTextWriter xmlWriter = null; string xmlString = ""; StringBuilder xmlStringBuilder = new StringBuilder(); try { xmlStringWriter = new StringWriter(xmlStringBuilder); xmlWriter = new XmlTextWriter((xmlStringWriter); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(); //start document //populate xml However, the generated xml string contains the header as: Does anybody know of a way to use enconding "utf-8" when building an xmldoc inside a string?
It appears that you did not check the display message as-is (no HTML). Are you trying to save an XML document inside a single string to then include in a second instance of something else (be it a XML doc or what ever?) "I will find a new sig someday."