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:
I load the XML 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>
Now i find the <Placemark> element with the id attribute I want like this:PHP Code:$xmlfile= 'universities.xml';
$xml = simplexml_load_file($xmlfile) or die("Αρχείο XML δε βρέθηκε");
$institutions=$xml->children();
What do I have to do to remove this particular element?PHP Code:foreach ($institutions as $institution) {
if ($institution['id']==$id) {
$current_uni = $institution;
}
}
Thank you in advanced.![]()


Reply With Quote

Bookmarks