Skip to content Skip to sidebar Skip to footer

Xslt: Parsing Html Embedded In Xml?

On my web site I have XMLs with my page contents (automatically generated from my DB) - which are displayed using XSLT. The problem is this: I'd like to have some formatting within

Solution 1:

<xsl:value-of select="content" /> 

outputs the value of a node. And the value of your <content> node actually is:

This is an article. It's HUGE, and here's a link

What you probably need is to copy the entire node:

<xsl:copy-of select="content" /> 

This is largely a guess since I don't know how your system works.

Solution 2:

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

This works on all browsers except Firefox.

Solution 3:

I think your problem is this:

 <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
          media-type="application/html+xml" encoding="utf-8" omit-xml-declaration="yes" indent="no"/>

make sure your output is of type html,

application/html

Solution 4:

Either encode your html when you embed it plainly in an elemnet, or use a CDATA block to preserve actual text. Either should work although depending on where the Transform takes place (like browser level via JS) the output may be different with encoded entities.

Solution 5:

You could change the generation of that XML file to put the content in a <![CDATA[ ]]> section, which tells the parser to ignore special content within that section.

Post a Comment for "Xslt: Parsing Html Embedded In Xml?"