I'm trying to read a saved location from data base using JavaScript from xml file my idea is to add markers to this map from the saved locations here is the xml code,is there is something wrong in my method of reading xml??:
<?php
$conn=mysqli_connect("localhost", "thecode007", "007","offers") or die(mysql_error());
$query = "SELECT BLocation FROM Branches";
$result = mysqli_query($conn,$query) or die(mysql_error());
$doc = new DomDocument('1.0');
$node = $doc->createElement("markers");
$parnode = $doc->appendChild($node);
header("Content-type: text/xml");
while($row = mysqli_fetch_array($result))
{
$node = $doc->createElement("marker");
$newnode = $parnode->appendChild($node);
$loc=explode(",",$row[0]);
$newnode->setAttribute("lat", $loc[0]);
$newnode->setAttribute("lon",$loc[1]);
}
print $doc->saveXML();
?>
//this code is working
the other code which is not working the map appears but the location inside that xml files are not appearing:
<!--the code up is the map code which is displayed well the problem is downhere-->
var marker = new google.maps.Marker({position:latlon1,map:map,title:" here!"});
var request = new XMLHttpRequest();
request.open("GET", "http://localhost/xml.php", false);
request.send();
var xml = request.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var lan2=markers[i].getAttribute("lat");
var lon2=markers[i].getAttribute("lon");
var latlon2= new google.maps.LatLng(lan2,lon2);
marker = new google.maps.Marker({position:latlon2,map:map,title:" here!"});
}
<!--the rest is working-->
</div>