cle*_*tus 14
当然可以使用SimpleXML进行编辑:
$input = <<<END
<?xml version='1.0' standalone='yes'?>
<documents>
  <document>
    <name>spec.doc</name>
  </document>
</documents>
END;
$xml = new SimpleXMLElement($input);
$xml->document[0]->name = 'spec.pdf';
$output = $xml->asXML();
看看这些例子.
使用SimpleXML加载XML并进行更改.然后,您可以使用asXML方法将XML保存到文件中(将文件名作为参数传递):
$xml = new SimpleXMLElement( $xmlString );
// do the manipulation here
$xml->asXML ( '/path/to/your/file.xml' );