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 に答える