HI, I need your help XML experts,I am have this kind of error when
I run this in my url http://localhost/maps/mymap.php?lat=37&lng=-122&radius=25
XML Parsing Error: junk after document element
Location: http://localhost/maps/mymap.php?lat=37&lng=-122&radius=25
Line Number 2, Column 1:<font size=‘1’><table class=‘xdebug-error xe-warning’ dir=‘ltr’ border=‘1’ cellspacing=‘0’ cellpadding=‘1’>
^
This is the code
<?php
$center_lat = $_GET["lat"];
$center_lng = $_GET["lng"];
$radius = $_GET["radius"];
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
try{
$stringconnection = new PDO("mysql:host=localhost;dbname=mydb", 'root', '');
$stringconnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$cmd = $stringconnection->prepare("SELECT storename,address,lat,lng ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM tblstore HAVING distance < '%s' ORDER BY distance LIMIT 0 , 20",
$center_lat,$center_lng,$radius
);
header("Content-type: text/xml");
while($row = $cmd->fetch(PDO::FETCH_OBJ)){
$node = $dom->createElement("marker");
$newnode = $parnode->appendChild($node);
$newnode->setAttribute("store name", $row->storename);
$newnode->setAttribute("address", $row->address);
$newnode->setAttribute("lat", $row->lat);
$newnode->setAttribute("lng", $row->long);
$newnode->setAttribute("distance", $row->distance);
}
echo $dom->saveXML();
}
catch(PDOException $ex){
echo $ex->getMessage();
exit();
}
please help me how to solve this.
Thank you in advance.