<xml>
<ns:foo attribute="bar">
OLD TEXT DATA
</ns:foo>
</xml>
我使用 XPath 来处理 XML 名称空间。这不起作用:
$xml->asXML('old.xml');
foreach ($xml->xpath('ns:foo') as $foo) {
$foo['attribute'] = 'new bar';
$foo = 'NEW TEXT DATA'; //This won't be saved by asXML().
}
$xml->asXML('new.xml');
如何更改文本内容SimpleXMLElement::xpath
?