Hi,
I am trying to transform input xml to output using XSLT. I use xsltranform class to do that. Although, both my input xml & xsl (using xsl:output encoding=\”utf-8\” statement) state utf-8, I always get utf-16 encoded output document.
Is there a way to change that?
My original code was:
StringBuilder sb = new StringBuilder();
TextWriter tw = new StringWriter(sb);
XslTransform xsl = new XslTransform();
xsl.Load(xslFile);
xsl.Transform(doc, null, tw, null);
XmlDocument ret = new XmlDocument();
ret.LoadXml(sb.ToString());
return ret;
which I later changed to use memorystream, as per the suggestion posted elsewhere on the web:
MemoryStream ms = new MemoryStream();
xslt.Transform(xDoc, null, ms);
ms.Position = 0;
StreamReader sr = new StreamReader(ms, Encoding.UTF8);
transformedXml = sr.ReadToEnd();
This still does not work…
Any suggestions?
Thanks