Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.NET XSLT output encoding

Status
Not open for further replies.

chiph

Programmer
Jun 9, 1999
9,878
US
Has anyone run into a problem with the .NET XSLT engine not respecting your output encoding?

I have my XSL file like this:
Code:
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform&quot;>[/URL]
	<xsl:output version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;/>
	<xsl:template match=&quot;/&quot;>
		<ChipData>
			<xsl:value-of select=&quot;Data1&quot;/>
		</ChipData>
	</xsl:template>
</xsl:stylesheet>
and the XML it produces has the encoding set to UTF-16, which is not what I wanted, nor specified.

The code I'm using to do the transform (in C#) is:
Code:
	XmlDocument MyDoc = new XmlDocument();
	MyDoc.LoadXml(MyValidXML);
	XPathNavigator MyNav = MyDoc.CreateNavigator();

	MyTransform = new XslTransform();
	MyTransform.Load(XSLPath);
	StringWriter sw = new StringWriter();
	MyTransform.Transform(MyNav, null, sw);

	ReturnXML = sw.ToString();

Thanks in advance.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top