<?php
$xml=simplexml_load_string(<<<XML
<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>
XML
);
function deleteNode($feed_id)
{
global $xml;
$node=$xml->xpath('//feed[@id=" '.$feed_id.' "]');
$node=dom_import_simplexml($node[0]);
$parent=$node->parentNode;
$parent->removeChild($node);
$xml=simplexml_import_dom($parent->ownerDocument);
}
echo $xml->asXML();
echo "\n";
deleteNode("9");
echo $xml->asXML();
- Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- <?xml version="1.0"?>
<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>
<?xml version="1.0"?>
<element>
</element>
preferences:
282.94 ms | 405 KiB | 415 Q