脚本宝典收集整理的这篇文章主要介绍了如何在PHP 5中启用XSLT功能?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我认为这意味着xslt功能尚未启用.如何在PHP中启用这些功能?我需要包含一个PHP文件(就像Javascript库的工作方式)还是更复杂的东西?我主持了MediaTemple.
<?PHP // Allocate a new XSLT PRocessor $xh = xslt_create(); // Process the document,returning the result into the $result VARiable $result = xslt_process($xh,'armstrong.xML','familyToNestedList.xsl'); if ($result) { print "SUCCESS,sample.xml was transformed by sample.xsl into the \$result"; print " variable,the \$result variable has the following contents\n<br>\n"; print "<pre>\n"; print $result; print "</pre>\n"; } else { print "Sorry,sample.xml Could not be transformed by sample.xsl into"; print " the \$result variable the reason is that " . xslt_error($xh) . print " and the error code is " . xslt_errno($xh); } xslt_free($xh); ?>
提前致谢!
从第Installation章开始
recommended extension for using XSL transformations with PHP5 is XSL.如果你需要做的就是转换两个文档,如你的例子中所示,请考虑PHP手册中的这个例子:
$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.无论如何,升级代码应该是微不足道的.
以上是脚本宝典为你收集整理的如何在PHP 5中启用XSLT功能?全部内容,希望文章能够帮你解决如何在PHP 5中启用XSLT功能?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。