I have XML:
<root>
<level name="main">
<level name="sub_1">
<content id="abc123" />
</level>
</level>
</root>
I would like to find node c id, which abc123u delete <content>and its parent<level>
So, the end result will be:
<root>
<level name="main">
</level>
</root>
I tried this in PHP with no result, what am I doing wrong?
$doc = new DOMDocument;
$doc->loadxml($xml_from_file);
$xpath = new DOMXPath($doc);
$node_list = $xpath->query("content[@id='abc123']/parent::*");
$node = $node_list->item(0);
$doc->removeChild($node);
source
share