So, I am working with .NET. I have an XSL file, XslTransform object in C# that reads in the XSL file and transforms a piece of XML data (manufactured in-house) into HTML.
I notice that my final output has < and > automatically encoded into < and >. Is there any ways I can prevent that from happening? Sometimes I need to bold or italicize my text but it's been unintentionally sanitized.
(XslTransform is deprecated, according to MSDN. They recommend you switch to XslCompiledTransform.)
Can you post an example of the input/output?
Your xsl file should have:
i.e.
And you should ideally use the overloads that accept either a
TextWriter
or aStream
(notXmlWriter
) - i.e. something like:In the xslt, if you really want standalone
<
/>
(i.e. you want it to be malformed for some reason), then you need to disable output escaping:However, in general it is correct to escape the characters.
I have used this in the past to transform XMl documents into HTML strings which is what you need.