I want to delete particular node in XML based on the id I passed in the xml. The below seems not working please help me.
$id = $_GET['nodeId'];
$dom = new DOMDocument;
$dom->load('Seat_matrix.xml');
$xpath = new DOMXPath($dom);
$query = sprintf('/location/cubicle[./id = "%d"]', $id);
foreach($xpath->query($query) as $cubicle) {
$record->parentNode->removeChild($cubicle);
}
$dom->save("Seat_matrix.xml");
XML file
<location>
<cubicle>
<id> 6121</id>
<status>2</status>
<shift1>
<Employee1>Tom</Employee1>
</shift1>
<shift2>
<Employee2>arum</Employee2>
</shift2>
</cubicle>
</location>