<root>
<vipfriends>
<friend>
<name>Mach</name>
<password>12345678</password>
<priviledge>vip</priviledge>
<sex>male</sex>
<tel>02552345332</tel>
<category>Business</category>
<view>myview</view>
<record>test</record>
<emails>
<email>[email protected]</email>
<email>[email protected]</email>
<email>[email protected]</email>
</emails>
</friend>
<friend>
<name>Tom</name>
<password>42345678</password>
<priviledge>special</priviledge>
<sex>female</sex>
<tel>13076587654</tel>
<view>myview</view>
<category>Friend</category>
<record>tees</record>
<emails>
<email>[email protected]</email>
<email>[email protected]</email>
<email>[email protected]</email>
</emails>
</friend>
...
</vipfriends>
</root>如何能根据<name>找删除掉整个<friend>节点呢 比如我想查到name = Tom 的friend节点 然后删除friend ,请各位赐教
解决方案 »
- php session_start()导致页面无法访问
- 关于cookies的使用
- linux下实现网络负载均衡 [
- 我是做Delphi开发的,现在需要用到PHP,问个简单的问题..(结贴率100%)
- 急,怎样在PHP中限制不让输入全角字符?
- 请问如何读取cookie数组中的某一个值...........
- 求助帖!关于__call的用法!输出让我觉得十分奇怪!!!
- Apache启动错误:The requested operation has failed!昨天刚配置好,能正常运行了,今天重启机子就不能用了.
- 在apache下运行php,能用这样的语句吗?
- 很菜的问题mysql_db_query和mysql_query在功能上有什么区别
- 数据库查询问题.在线等
- $_POST["name"]不能返回数组吗?
http://www.php.net/manual/en/book.domxml.php
return $node->getElementByTagName().fristChild.nodeValue;
}
$rootNode = $xmlDoc->getElementsByTagName('vipfriends')->item(0);
$nodes = $rootNode->getElementsByTagName('friend');
$x = 0;
$length = $nodes->length;
//由于删除一个节点会影响数组长度,所以要特殊处理
while($length > $x){
$temp = $nodes->item($x);
if(($temp->getElementsByTagName('name')->item(0)->nodeValue) == 'Tom'){
$rootNode->removeChild($temp);
$x--;
$length--;
}
$x++;
}