调用XSL样式表的最简单方法可能是在任何XML文件中添加第二行,如下所示:
<?xml-stylesheet type="text/xsl" href="yourstylesheet.xsl"?>
但是,我听说过其他方法 - 最好是一种不需要篡改XML文件而不依赖任何特定平台(开放格式解决方案)的方法。
有什么建议吗?
非常感谢提前。
/保
<?php
// Load XML file
$xml = new DOMDocument;
$xml->load('cdcatalog.xml');
// Load XSL file
$xsl = new DOMDocument;
$xsl->load('cdcatalog.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
// Attach the xsl rules
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);
?>