标签:style blog io ar color sp for on div
需要修改的xml
<?xml version="1.0"?> <config> <administration> <adminuser> <user> <id type="autoinc">1</id> <name type="username" min="3" max="20">admin</name> <passwdmd5 type="passwd" min="4" max="10">21232f297a57a5a743894a0e4a801fc3</passwdmd5> <purview type="purview">super</purview> </user> </adminuser> </administration> </config>
用php修改xml的节点
$doc = new DOMDocument; $doc->load(‘test.xml‘); $users = $doc->documentElement->getElementsByTagName(‘user‘); foreach($users as $user) { $purviews = $user->getElementsByTagName(‘purview‘); $purview = $purviews->item(0); $tmpNode = $purview->cloneNode(); $tmpNode->nodeValue = "xxx"; $tmpNode = $purview->parentNode->appendChild($tmpNode); $purview->parentNode->replaceChild($tmpNode,$purview); $doc->save("test1.xml"); }
标签:style blog io ar color sp for on div
原文地址:http://www.cnblogs.com/itafter/p/4121112.html