作者asdd (我爱胖颖颖)
看板PHP
标题[请益] 利用php处理XML+XSLT
时间Sat Jan 15 20:30:12 2011
我要利用PHP让处理XML+XSL,因为要让他自动呈现不用自动转换,所以在网路上找到以下
的程式码来处理,可是一直会有错误Parse error: syntax error, unexpected T_VARIABLE
$xmlfile = file_get_contents("C:\\xampp\\htdocs\\xml_search.xml");
$xslfile = file_get_contents("C:\\xampp\\htdocs\\xml_search.xsl");
$arguments=array("/_xml"=>$xmlfile,"/_xsl"=>$xslfile) ;
$xh = xslt_create();
$result=xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$arguments);
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);
我手动转换是可以正确显示的,但是想要自动转换就有问题了
不过我看了超久实在看不出哪里有问题,麻烦各位帮我看一下 谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.137.56
1F:→ asdd:找了一整天终於知道php5没有支援xslt_create() 01/16 02:47