0

xml通过调用页面得到了这个结果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>

我使用这个 jquery 脚本检索 xml 响应:

$(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);

                    });
                }
            });
        });

编辑

这是getRout.php文件的内容..

<?
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.1799&v=motorcar&fast=1&layer=mapnik";
header("Content-type:text/xml");
$result = RestClient::get($url,$inputs); 
echo($result->getResponse());
?>
4

1 回答 1

0

看看getRout.php?>结束标签后有空格吗?您可以尝试完全删除结束标签,以确保没有额外的空格被添加到您的响应中。

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

于 2011-09-12T18:45:36.193 回答