我需要从返回 XML 格式数据的 .NET Web 服务访问响应。如何拆分返回的数据?例如,我想将数据解析为一些 PHP 变量:
$name = "Dupont";
$email = "charles.dupont@societe.com";
我一直在寻找如何做到这一点,但没有找到正确的方法。
我的脚本是:
$result = $client->StudentGetInformation($params_4)->StudentGetInformationResult;
echo "<p><pre>" . print_r($result, true) . "</pre></p>";
我页面中的回声是:
stdClass Object
(
[any] => 0Successful10371DupontCharlescharles.dupont@societe.com1234charles.dupont@societe.comfalsefr-FR1003FIRST FINANCE1778AAA Département
)
网络服务响应格式为:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<StudentGetInformationResponse xmlns="http://tempuri.org/">
<StudentGetInformationResult>xml</StudentGetInformationResult>
</StudentGetInformationResponse>
</soap:Body>
</soap:Envelope>
我试过你的例子。但它不能满足我的需要。我需要拆分返回的值。我想获取数据并将它们放入 PHP 变量中:
$name = "杜邦"; $email = "charles.dupont@societe.com"; ETC...
不幸的是,您的示例的回声给出了:
object(stdClass)#1 (1) { ["StudentGetInformationResult"]=> object(stdClass)#11 (1) { ["any"]=> string(561) "0Successful10371DupontCharlescharles.dupont@societe.com1234charles.dupont@societe.comfalsefr-FR1003FIRST FINANCE1778AAA Département" } }