RSS订阅
DOM操作节点读取,
节点创建与追加
节点删除
<?php //创建DOM对象 $dom = new DOMDocument(‘1.0‘,‘utf-8‘); //载入XML $dom->load(‘01.xml‘); //把天龙八部从商品删除 //查找goods节点,从列表中选取天龙八部节点 $tl = $dom->getElenmentByTagName(‘goods‘)->item(0); $t1->parentNode->removeChild($tl); /*header(‘content-type:text/xml‘); $dom->savexml();*/ //修改节点,节点不能修改,只能替换 $name = $dom->getElenmentByTagName(‘name‘); $seveb = $dom->createTextnode(‘七种武器‘); $name = replaceChild($seveb,$name->firstChild); header(‘content-type:text/xml‘); $dom->savexml(); ?> |
getElenmentByTagName得到的还是一个节点
本文出自 “杜国栋个人PHP学习博文” 博客,请务必保留此出处http://duguodong.blog.51cto.com/7667978/1387192
时间:2014年3月28日21:00:49DOM节点的删与改,布布扣,bubuko.com
时间:2014年3月28日21:00:49DOM节点的删与改
原文:http://duguodong.blog.51cto.com/7667978/1387192