Transforming XML with XSL and PHP 4


 $result = $xslt->process($dom); echo $xslt->result_dump_mem($result); 


To use XSL Transformations (XSLT) with PHP, you again have to decide first which PHP version to use. If it's PHP 4, you have to use extension=php_xslt.dll in php.ini (Windows), or install Sablotron from http://www.gingerall.com/and use the configuration switches enable-xslt with-xslt-sablot (for other systems).

Using XSLT with PHP 4 (xslt4.php)
 <?php   $dom = domxml_open_mem(file_get_contents('quotes.xml'));   $xslt = domxml_xslt_stylesheet( file_get_contents('quotes.xsl'));   $result = $xslt->process($dom);   echo $xslt->result_dump_mem($result); ?> 

Doing the transformation is a number of four easy steps: Load the XML; load the XSLT; execute the transformation; and, finally, save the result. The preceding phrase contains the code for these steps; the file quotes.xsl in the download repository contains markup that transforms the quotes' XML into the well-known HTML bulleted list.




PHP Phrasebook
PHP Phrasebook
ISBN: 0672328178
EAN: 2147483647
Year: 2005
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net