繁体   English   中英

在php中查看来自Web服务响应的xml内容结果

[英]view xml content result from web service response in php

我正在创建连接到Web服务的php页面,并将显示来自Web服务的结果,Web服务响应的xml如下所示:

<GetUserResponse xmlns="http://the web service">
  <GetUserResult>
    <xsd:schema>schema</xsd:schema>xml
  </GetUserResult>
</GetUserResponse>

我需要知道从服务获得的xml内容,以及如何处理它或将其显示在页面中?


解决了

我能够使用以下方法解决它:

$ xml = simplexml_load_string($ result);

XML File : myxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
    <to>Gauttam</to>
    <from>Kevadia</from>
    <heading>My Heading</heading>
    <body>Body Content Here!!!!</body>
</note> 

TO read in PHP return with Object :

<?php
    $xml=simplexml_load_file("myxml.xml");
    echo $xml->to . "<br>";
    echo $xml->from . "<br>";
    echo $xml->heading . "<br>";
    echo $xml->body;
    // IF XML file having multiple value retrieve it dynamic with array 
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM