PHP XSL
example xml & xsl
http://uk.php.net/manual/en/xsl.examples-collection.phpexample php xsl
// Load the XML source
$xml = new DOMDocument('1.0','utf-8');
$xml->load('collection.xml');
$xsl = new DOMDocument('1.0','utf-8');
$xsl->load('collection.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToDoc($xml)->saveHTML();
echo PHP_EOL;
echo $proc->transformToDoc($xml)->saveXML();
echo PHP_EOL;
echo $proc->transformToXML($xml);
echo PHP_EOL;
$xml = new DOMDocument('1.0','utf-8');
$xml->load('collection.xml');
$xsl = new DOMDocument('1.0','utf-8');
$xsl->load('collection.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToDoc($xml)->saveHTML();
echo PHP_EOL;
echo $proc->transformToDoc($xml)->saveXML();
echo PHP_EOL;
echo $proc->transformToXML($xml);
echo PHP_EOL;
transformToDoc($xml)->saveHTML() output
Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection! <h1>Fight for your mind</h1><h2>by Ben Harper - 1995</h2><hr> <h1>Electric Ladyland</h1><h2>by Jimi Hendrix - 1997</h2><hr>
transformToDoc($xml)->saveXML() output
<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?> Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection! <h1>Fight for your mind</h1> <h2>by Ben Harper - 1995</h2> <hr/> <h1>Electric Ladyland</h1> <h2>by Jimi Hendrix - 1997</h2> <hr/>
transformToXML($xml) output
Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection! <h1>Fight for your mind</h1><h2>by Ben Harper - 1995</h2><hr> <h1>Electric Ladyland</h1><h2>by Jimi Hendrix - 1997</h2><hr>
REFERRERS
PhpXml