使用php+xslt在windows平台上
程序员文章站
2023-01-29 22:32:14
在windows平台上使用php+xslt1。到http://www.php.net下载php 4.0.62。将php-4.0.6-win32.zip解压到c:\php下3...
在windows平台上使用php+xslt
1。到http://www.php.net下载php 4.0.6
2。将php-4.0.6-win32.zip解压到c:\php下
3。在web server上配置好php
3。拷贝dlls目录下的下列四个文件到windows\system(32)下
expat.dll
sablot.dll
xmlparser.dll
xmltok.dll
4。修改php.ini
修改extension_dir指向正确的extension目录
extension_dir = c:/php/extensions
然后找到下面这行
;extension=php_sablot.dll
修改为:
extension=php_sablot.dll
如果php配置的是cgi模式,则不需要重启web server,否则可能需要重启web server
5。我们用例子来测试一下
test.xml
============================
<?xml version="1.0"?>
<articles>
<article>
this is the first article.
</article>
</articles>
test.xsl
============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="articles/article"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
test.php
===========================
<?php
$parser=xslt_create();
xslt_run($parser,'test.xsl','test.xml');
print xslt_fetch_result($parser);
xslt_free($parser);
?>
最后,该parser不支持gb2312。:(
1。到http://www.php.net下载php 4.0.6
2。将php-4.0.6-win32.zip解压到c:\php下
3。在web server上配置好php
3。拷贝dlls目录下的下列四个文件到windows\system(32)下
expat.dll
sablot.dll
xmlparser.dll
xmltok.dll
4。修改php.ini
修改extension_dir指向正确的extension目录
extension_dir = c:/php/extensions
然后找到下面这行
;extension=php_sablot.dll
修改为:
extension=php_sablot.dll
如果php配置的是cgi模式,则不需要重启web server,否则可能需要重启web server
5。我们用例子来测试一下
test.xml
============================
<?xml version="1.0"?>
<articles>
<article>
this is the first article.
</article>
</articles>
test.xsl
============================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="articles/article"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
test.php
===========================
<?php
$parser=xslt_create();
xslt_run($parser,'test.xsl','test.xml');
print xslt_fetch_result($parser);
xslt_free($parser);
?>
最后,该parser不支持gb2312。:(
上一篇: 朋友网关于QQ相关的PHP代码(研究QQ的绝佳资料)
下一篇: 用PHP发电子邮件
推荐阅读