On PHP 5, XSLT is done by libxslt and can be enabled using php_xsl.dll (in php.ini) on Windows and the switch with-xsl on other platforms. The approach is a bit different: Load both the XML and the XSLT (which is an XML document, as well) into a DOM object, then instantiate an XsltProcessor object. Call importStylesheet() and then transformToDoc(). Using XSLT with PHP 5 (xslt5.php)<?php $xml = new DOMDocument(); $xml->load('quotes.xml'); $xsl = new DOMDocument(); $xsl->load('quotes.xsl'); $xslt = new XsltProcessor(); $xslt->importStylesheet($xsl); $result = $xslt->transformToDoc($xml); echo $result->saveXML(); ?>
|