[RESOLVED] Removing particular XML elements with SimpleXML
Hello everyone.
I am trying to edit an element on a XML file with SimpleXML, and as far as I am concerned I have to remove the old one and then add the new one. First of all, my XML file is like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<Placemark id="1000"><!-- children elements --></Placemark>
<Placemark id="1001"><!-- children elements --></Placemark>
<Placemark id="1002"><!-- children elements --></Placemark>
...
</Document>
I load the XML like this:
PHP Code:
$xmlfile= 'universities.xml';
$xml = simplexml_load_file($xmlfile) or die("Αρχείο XML δε βρέθηκε");
$institutions=$xml->children();
Now i find the <Placemark> element with the id attribute I want like this:
PHP Code:
foreach ($institutions as $institution) {
if ($institution['id']==$id) {
$current_uni = $institution;
}
}
What do I have to do to remove this particular element?
Thank you in advanced. :)