0

I am trying to style an RSS document containing a description with HTML. I am unable to display this HTML using XSLT, in the Firefox browser.

This is the XML document:

<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/xsl' href='/css/rss.xsl' media='all' ?>
<rss version='2.0'>
    <channel>
        <item>
            <description>
                <![CDATA[<p>This is the description</p>]]>
            </description>
        </item>
    </channel>
</rss>

I've tried this XSLT command, but it shows the HTML:

<xsl:copy-of select="description"/></li>

This didn't work either:

<xsl:value-of select="description" disable-output-escaping="yes"/>
Ed Bangga
  • 12,879
  • 4
  • 16
  • 30
bart
  • 14,958
  • 21
  • 75
  • 105
  • Please add closing for cdata section like <![CDATA[

    This is the description

    ]]> in your input xml
    – imran Dec 21 '18 at 04:16
  • @imran Good call, fixed it in above example, but problem remains. – bart Dec 21 '18 at 21:26
  • It's not clear what kind of output you expect. Keep in mind that the content of `description` is **not** HTML. It is a string equivalent to escaped HTML. --- Also, "didn't work" is not a useful description. Tell us what the actual result was - and what exactly did you use to get it. – michael.hor257k Dec 21 '18 at 22:01
  • @michael.hor257k I want the HTML to be interpreted. So string would show as bold. – bart Dec 21 '18 at 22:05
  • @michael.hor257k Are you staying I should remove <![CDATA[]]> to display HTML? – bart Dec 21 '18 at 22:06
  • I am saying that if your data provider wants you to interpret the contents as HTML code, then they should not put it inside a CDATA section. -- And I am also saying you need to explain what your environment is. The result of an XSL transformation is a plain-text document. Nothing shows as bold in a plain-text document. – michael.hor257k Dec 21 '18 at 22:20
  • @michael.hor257k Environment: Firefox browser reading XML and applying XLS. – bart Dec 21 '18 at 22:26
  • AFAIK, Firefox does not do `disable-output-escaping`. See (for example): https://stackoverflow.com/questions/16086755/parse-html-inside-the-cdata-text – michael.hor257k Dec 21 '18 at 22:43
  • @michael.hor257k That's the problem I am reporting :) How to solve it? – bart Dec 21 '18 at 22:45

0 Answers0