Anaximines Posted June 17, 2009 Share Posted June 17, 2009 Hi, I have what I hope is a simple question and I apologize if it has been covered somewhere else but I searched around and couldn't find anything. I'm trying to use a PHP file (deleteMarker.php) to search a XML file full of google maps markers with the following structure: <marker lat="XXXXX" lng="YYYYY" comment="ZZZZZ"/><marker .../>... for the marker with the lat value matching that of a JavaScript variable (markerlatitude) and then remove that marker. Here is the JavaScript and PHP that I have so far (init() just reinitializes the map): function deleteMarker() { var markerlatitude = document.getElementById("markerlatitude").value; var getVar = "?markerlatitude=" + markerlatitude; var request = GXmlHttp.create(); //open the request to deleteMarker.php on server request.open('GET', 'deleteMarker.php' + getVar, true); request.onreadystatechange = function() { if (request.readyState == 4) { init(); } } request.send(null); return false; } <?php header('Content-Type: text/xml;charset=UTF-8'); $markerlatitude = (float)$_GET['markerlatitude']; $xdoc = new DOMDocument(); $xdoc->load('data.xml'); $lats = $xdoc->getElementsByTagName('marker')->item(0); foreach ($lats as $lat) { if ($lat == $markerlatitude) { $xdoc->documentElement->removeChild($lat); } } $xdoc->save('data.xml'); ?> Any help I could get on this would be greatly appreciated, I'm really not sure why it's not working. Thanks, Eric Link to comment https://forums.phpfreaks.com/topic/162574-php-to-delete-xml-element/ Share on other sites More sharing options...
Anaximines Posted June 17, 2009 Author Share Posted June 17, 2009 This problem is fairly urgent, I'd be glad to paypal $25 to the first person who can help me get this working. Link to comment https://forums.phpfreaks.com/topic/162574-php-to-delete-xml-element/#findComment-858243 Share on other sites More sharing options...
Anaximines Posted June 19, 2009 Author Share Posted June 19, 2009 FYI in case anyone's interested the problem was that the server had DOM disabled in PHP. Link to comment https://forums.phpfreaks.com/topic/162574-php-to-delete-xml-element/#findComment-859694 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.