开发者

What is the reason of such error " XML or text declaration not at start of entity" when parsing xml?

I have this xml result from calling the page getRout.php

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://earth.google.com/kml/2.0"> 
  <Document> 
    <name>KML Samples</name> 
    <open>1</open> 
    <distance>20.831418618295</distance> 
    <description>To enable simple instructions add: 'instructions=1' as parameter to the URL</description> 
    <Folder> 
.
.
.
.
</kml>

I use this jquery script retrieve xml response :

$(document).ready(function(){
            $.ajax({
                type: "GET",
                url: "getRout.php",
                dataType: "xml",
                success: function(xml) {
                    $(xml).find('coordinates').each(function(){
                            var t = $(this).text();
                            alert(t);

                    });
                }
            });
        });

edit

this is the content of getRout.php file ..

<?
require_once "RESTclient.class.php";
$url = "http://www.yournavigation.org/api/1.0/gosmore.php?format=kml&flat=52.215676&flon=5.963946&tlat=52.2573&tlon=6.17开发者_如何学C99&v=motorcar&fast=1&layer=mapnik";
header("Content-type:text/xml");
$result = RestClient::get($url,$inputs); 
echo($result->getResponse());
?>


Take a look at getRout.php. Is there whitespace after the closing ?> tag? You can try removing the closing tag altogether to ensure that no extra whitespace is being added to your response.

https://softwareengineering.stackexchange.com/questions/89553/closing-tag-on-php-files

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜