BarryFanta
BarryFanta

Reputation: 69

how to stop xslt from rendering html markup

I have this xml:

<Chapter>
  <Question>Some details in bullet format here <ul><li> point1 </li> <li></li> </ul>
</Question>
</Chapter>

My XSLT (version 1.0) has this:

<xsl:for-each select="Question">
      <xsl:value-of select="."/>
    </xsl:for-each>

My output looks like this:

"Some details in bullet format here &lt;li&gt; point1 &lt;li&gt;point2&lt;li&gt;"

Instead of the intended html bullet points.

Expected result:

Some details in bullet format here

Any suggestions please?

Upvotes: 1

Views: 223

Answers (2)

BarryFanta
BarryFanta

Reputation: 69

This fixed it:

 <xsl:value-of select="string(.)" 
                    disable-output-escaping="yes"/>

Since the markup was being HTML encoded for whatever reason and the disable tag stops that.

More details here: After trasforming XML in HTML with XSLT, HTML tags get "stripped"

Upvotes: 0

gp.
gp.

Reputation: 8225

use <xsl:copy-of select="node()"/>

Upvotes: 2

Related Questions