1、<?php $xmlDoc = new DOMDocument(); $xmlDoc->load("data.xml"); $xml = new SimpleXMLElement($xmlDoc->saveXML()); $xml->administration->adminuser->user->purview = 'xxx'; file_put_contents('xxx.xml', $xml->asXML()); ?> $xml = new SimpleXMLElement(file_get_contents('data.xml')); $xml->administration->adminuser->user->purview = 'xxx'; file_put_contents('xxx.xml', $xml->asXML()); $xml = simplexml_load_file('test.xml'); $xml->administration->adminuser->user->purview = 'xxx'; file_put_contents('xxx.xml', $xml->asXML());