try<?php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->load('example.xml');$xsl = new DomDocument;
$xsl->load('example.xsl');/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?> 详见
http://www.php.net/manual/en/ref.xsl.php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->load('example.xml');$xsl = new DomDocument;
$xsl->load('example.xsl');/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?> 详见
http://www.php.net/manual/en/ref.xsl.php
当然后者要比前者要好的多!如果你是想兼容php4下的代码,那么请连接php_xslt.dll(php,ini中没有,就加进去)
如果你是想重写,那么请加载php_xsl.dll
手册上说:This extension is EXPERIMENTAL. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk.
这个扩展处于试验阶段...我是看了这段话才想用xslt的,另外在PHP5中是加载不了php_xslt.dll的。
php_xslt.dll是可以加载的,加在php_xslt.dll的条件我想你不会不知道吧
前者以libxslt为基础,而后者则是Sablotron。
PHP Startup:Unable to load dynamic library '.\ext\php_xslt.dll' - 找不到指定的模块