0

我将这个 Web 服务调用到我的 curl 文件中,并且响应是 XML 格式的。现在,当我在浏览器上预览时,它不显示 Google 地图,而是显示 html 标签。

$data= "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://services.webservices.vub.com/'>
           <soapenv:Header/>
           <soapenv:Body>
              <ser:googlemap>
                 <!--Optional:-->
                 <address>ijzerenmolenstraat, leuven Belgium</address>
              </ser:googlemap>
           </soapenv:Body>
        </soapenv:Envelope>";
$url="http://localhost:8080/Venue_Finder_Soap_Version_/VenueFinder?WSDL";
$response=curl_soappost_call($url,$data);
echo "<pre>";
print_r($response);
echo " </pre>";

输出:所有的html标签

4

1 回答 1

0

我会使用 jquery 将内容添加到 DOM。这样,新的 HTML、JS 和 CSS 将正确呈现/执行。尝试以下方法:

在页面的正文部分:

在您希望内容出现的页面上放置一个具有唯一 id 属性的空 div,例如:

 <div="the_google_map"></div>

在页面的头部:

 // include the jquery library (Can be downloaded and hosted on your own server if desired)
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

 $(document).ready(function(){  // don't run this code until the DOM is ready

    //  get the content  
    $data= "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://services.webservices.vub.com/'>
               <soapenv:Header/>
               <soapenv:Body>
                  <ser:googlemap>
                     <!--Optional:-->
                     <address>ijzerenmolenstraat, leuven Belgium</address>
                  </ser:googlemap>
               </soapenv:Body>
            </soapenv:Envelope>";
    $url="http://localhost:8080/Venue_Finder_Soap_Version_/VenueFinder?WSDL";
    $response=curl_soappost_call($url,$data);

    // use jquery to insert the content into the DOM
    // Note the div id value here matches the div id used in the body
    $('#the_google_map').append($response);


 });
于 2013-07-29T13:26:19.430 回答