以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XML源码及示例(仅原创和转载) 』  (http://bbs.xml.org.cn/list.asp?boardid=32)
----  php.xpath不能保存节点数据  (http://bbs.xml.org.cn/dispbbs.asp?boardid=32&rootid=&id=9880)


--  作者:minimu
--  发布时间:9/10/2004 9:45:00 AM

--  php.xpath不能保存节点数据
代码如下:
<?php
require_once("inc/XPath.class.php");
$xmlfile =& new XPath();
$xmlfile->importFromFile("file/news.xml");
echo $xmlfile->getData('/root/news/newscontent[1]');
$NewsNumber = $xmlfile->getAttributes('/root/news[1]', 'name') +1;
echo "$NewsNumber";
$NodeString = '<newstitle>测试1</newstitle>';
//一直到这儿都是正确的,但是下面插入节点就没有反应了,我看了返回值了,返回值$bInsert都已经生成了正确的XPath,但是XML文件没有被更新,是不是还要提交或者其他的操作,文档里面没有例子,帮忙啊
//$bInsert = $xmlfile->insertChild('/root/news[1]', $NodeString, FALSE, FALSE);
$bInsert = $xmlfile->insertBefore('/root/news[1]', $NodeString);
$xmlfile->reindexNodeTree();
?>
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms