Here my example code
PHP-File:
- Code: Select all
$xsl = new DOMDocument();
$xsl->load('test.xsl');
$xslProcessor = new XSLTProcessor();
$xslProcessor->importStylesheet($xsl);
$xml = new DOMDocument();
$xml->load('test.xml');
$doc = new DomDocument();
$doc = $xslProcessor->transformToDoc($xml);
echo $doc->saveXML();
File: text.xml
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<root>
<foo value="<h1>bar</h1>" />
</root>
File: text.xsl
- Code: Select all
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="foo">
foo:
<span><xsl:value-of select="@value" disable-output-escaping='yes' /></span>
</xsl:template>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="//foo" />
</body>
</html>
</xsl:template>
</xsl:stylesheet>

