我怎么删除父节点与XML PHP和保存更改XML查找节点家长和删除simplexml的PHP
我怎么努力
<element>
<feed id=" 9 ">
<title>test</title>
<table>feeds</table>
<link/>
<feed_type>API</feed_type>
<affiliate/>
<mwst>ja</mwst>
<tld>DE</tld>
<query/>
</feed>
</element>
public function deleteNode($feed_id){
//find feed on attribute ID
$node = $this->xml->xpath('//feed[@id =' . $feed_id . ' ]');
//find the parent and delete thenode
$element = $node[0]->xpath('parent::*');
// ??unset($element[0]);
$this->xml->asXML(SITE_ROOT . '/xml/feed_config.xml');
exit();
}
您可以使用'SimpleXml'来删除节点,请参阅http://stackoverflow.com/questions/13002313/php-simplexml-delete-please-tell-me-why-the-第一个变种是不工作的 – michi