2012-03-16 88 views

回答

3

这里

$proc = new XSLTProcessor(); 

$xsl = new DOMDocument(); 
$xsl->load("your.xsl"); // load XSL 

$xml = new DOMDocument(); 
$xml->load("your.xml"); // load XML 

$proc->importStylesheet($xsl); 
echo $proc->transformToXML($xml); // transform XML 

XSL docs are here

+0

当我尝试做这种方式的结果是一个致命的错误,因为没有找到DOMDocument类,任何解决方案? – Haritz 2012-03-16 15:51:12

+0

@Haritz参考文档 - [安装文档在这里](http://www.php.net/manual/en/dom.setup.php) – ManseUK 2012-03-16 15:56:54

+0

问题是通过运行phpinfo()我可以看到dom是安装并启用。我不知道为什么我不能运行DOMDocument() – Haritz 2012-03-16 16:01:01

1

至于你的XML问题简单的例子,看看PHP的SimpleXML的类。这里是一个详细的教程,说明如何加载XML文件以及如何开始对它进行分析:

Parsing XML with the SimpleXML class