php xml操作
<?xml version="1.0" encoding="UTF-8"?>
<root>
<admins>
<username>admin</username>
<password>xxxxxxxxxxxxxx</password>
</admins>
<admins>
<username>admin</username>
<password>xxxxxxxxxxxxxx</password>
</admins>
</root>
<root>
<admins>
<username>admin</username>
<password>xxxxxxxxxxxxxx</password>
</admins>
<admins>
<username>admin</username>
<password>xxxxxxxxxxxxxx</password>
</admins>
</root>
$filex = S_ROOT.'./data/adminconfig.xml';
$xml = simplexml_load_file($filex);
$result = $xml->xpath("//admins[username='".$_SESSION['user']."']");
$result[0]->password = md5($_POST['newpwd']); //关键在于 $result[0] 这里dump打印出来看结果就很明显了. 因为是xml对象 不能像数组那样直接复制 所有 xml -> tag
$xml = simplexml_load_file($filex);
$result = $xml->xpath("//admins[username='".$_SESSION['user']."']");
$result[0]->password = md5($_POST['newpwd']); //关键在于 $result[0] 这里dump打印出来看结果就很明显了. 因为是xml对象 不能像数组那样直接复制 所有 xml -> tag