0

I'm trying to create an XML file with a corresponding XSLT stylesheet. Everything sort of works okay, but...

...the nodes I'm outputting contain XHTML text inside them, like so:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <snippet id="user_surname">
        <content>
            <h1>Some title here</h1>
            <p>Blah blah blah...</p>
        </content>
    </snippet>
    ...
</root>

Here's the corresponding XSLT stylesheet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <xsl:for-each select="root/snippet">
      <div>
        <xsl:value-of select="content" disable-output-escaping="yes" />
      </div>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

The issue I'm having, is that the h1 and p tags are not printed as h1 and p tags, but instead, as plain text without the tags.

How can I get my XSLT stylesheet to print these tags as is? I tried wrapping in CDATA tags, but it doesn't seem to help.

Thanks in advance!

1 Answer 1

2

Try xsl:copy-of instead of xsl:value-of. That should give you the nodes instead of the nodes as text.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.