php5中使用xslt扩展,如何在PHP 5中启用XSLT功能?

您需要

compile PHP并支持它,并确保拥有所有必需的依赖项.请参阅

PHP Manual for XSLT中的相应章节.

This extension requires the libxml PHP extension. This means that passing in –enable-libxml is also required, although this is implicitly accomplished because libxml is enabled by default. This extension uses Sablotron and expat, which can both be found at » 07003. Binaries are provided as well as source. Enable by using the –with-xslt option with PHP 4.

On Unix, run configure with the –enable-xslt –with-xslt-sablot options. The Sablotron library should be installed somewhere your compiler can find it. Make sure you have the same libraries linked to the Sablotron library as those, which are linked with PHP. The configuration options: –with-expat-dir=DIR –with-iconv-dir=DIR are there to help you specify them. When asking for support, always mention these directives, and whether there are other versions of those libraries installed on your system somewhere. Naturally, provide all the version numbers.

$xml = new DOMDocument;

$xml->load('collection.xml');

$xsl = new DOMDocument;

$xsl->load('collection.xsl');

// Configure the transformer

$proc = new XSLTProcessor;

$proc->importStyleSheet($xsl); // attach the xsl rules

echo $proc->transformToXML($xml);

transformToXML方法将返回已转换的文档或FALSE,因此您可以保留代码中的if / else.无论如何,升级代码应该是微不足道的.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值