LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 933|回复: 3

php中的dom函数无法使用,phpinfo里面有啊!

[复制链接]
发表于 2005-4-1 08:05:05 | 显示全部楼层 |阅读模式
下面是phpinfo()显示的相关内容:

--with-xml' '--with-expat-dir=/usr' '--with-dom=shared,/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr'

系统是使用FC3,这说明php目前是支持dom、dom-xslt的,可是在使用

[PHP]
<?php
phpinfo();
//Transformer XML -> HTML par XSL
$CurrentDir = dirname(__FILE__);
$xmldoc = domxml_open_file("$CurrentDir\\sample.xml");
$xsldoc = domxml_xslt_stylesheet_file("$CurrentDir\\sample.xsl");
$result =  $xsldoc->process($xmldoc);
print $xsldoc->result_dump_mem($result);
?>
[/PHP]

的时候却出现下面错误:

……(省略phpinfo()输出)
Fatal error: Call to undefined function: domxml_open_file() in /data/www/html/index.php on line 5

这是怎么回事??
发表于 2005-4-1 08:14:31 | 显示全部楼层
你看一下手册看看?
我记得好像将函数名换了。
前几天看到的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-1 09:18:30 | 显示全部楼层
晕!那个例子就是手册上抄的啊!
而且是直接从php.net上面的手册抄的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-4-1 09:35:21 | 显示全部楼层
类似的,我使用以下代码:
vi.xsl:
[PHP]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:template match="TEST">
<xsl:value-of select="NAME"/><BR/>
</xsl:template>
</xsl:stylesheet>
[/PHP]

dom.php
[PHP]
<?php
$xml = new DOMDocument('1.0', 'utf-8'); //Change encoding to utf-8
$xsl = new DOMDocument;
$xsl->load('v1.xsl');
$proc = new XSLTProcessor;
$root = $xml->CreateElement("TEST");
$val = utf8_encode ('Andr?s Poluk'); //New Line
$child = $xml->CreateElement("NAME",$val);
$root->appendChild($child);
$xml->appendChild($root);
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);   
?>
[/PHP]

同样出现错误提示:
Fatal error: Cannot instantiate non-existent class: domdocument in d:\greenamp\www\dom.php on line 2

不过这次,我用的是apach1.3+php4.3.10+winxp。

但是我看手册中有这样一句话:

XXVII. DOM Functions
……
There is no installation needed to use these functions; they are part of the PHP core.


那如果是这样,为什么还会找不到函数呢?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表