How do I preserve markup tags?

xml, xslt

Solution

Try to use

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

instead. From w3schools' documentation on same:

The `<xsl:copy-of>` element creates a copy of the current node.

Note: Namespace nodes, child nodes, and attributes of the current node are automatically copied as well!

Problem

I've got an XML document containing news stories, and the body element of a news story contains p tags amongst the plain text. When I use XSL to retrieve the body, e.g. ``` <xsl:value-of select="body" /> ``` the p tags seem to get stripped out. I'm using Visual Studio 2005's implementation of XSL. Does anyone have any ideas how to avoid this? Thanks.

Original source