解析 PHP 肥皂响应
我收到来自 Bluegrace Shipping 的肥皂响应,任何人都可以帮助我从 simpleXMLLoadElement 对象中提取特定数据。我正在使用 Bluegrace Shipping 为 Magento 创建自定义运输模块,如果有人需要这个,我将分享我的模块。
这是我的代码
$xml = simplexml_load_string($output);
$ns = $xml->getNamespaces(true);
$soap = $xml->children($ns['soap']);
foreach ($soap->children($ns['Quote']) as $item)
{
print $item->children($ns['Total']).'<br>';
}
它将打印不带标签的完整响应字符串
下面是我得到的响应
<StatusCode>1</StatusCode>
<StatusMessage>StatusMessage1</StatusMessage>
<Quotes>
<Quote>
<Currency>NcName1</Currency>
<QuoteDate>QuoteDate1</QuoteDate>
<FreightTotal>1</FreightTotal>
<ServicesTotal>1</ServicesTotal>
<Total>1</Total>
<CarrierName>NcName1</CarrierName>
</Quote>
</Quotes>
I am getting soap response from Bluegrace shipping,Can anyone please help me to extract particular data from simpleXMLLoadElement object. I am creating custom shipping module for Magento with Bluegrace shipping, I will share my module if anyone needed this.
Here is my code
$xml = simplexml_load_string($output);
$ns = $xml->getNamespaces(true);
$soap = $xml->children($ns['soap']);
foreach ($soap->children($ns['Quote']) as $item)
{
print $item->children($ns['Total']).'<br>';
}
It will print complete string of response without tags
Below is the response that i am getting
<StatusCode>1</StatusCode>
<StatusMessage>StatusMessage1</StatusMessage>
<Quotes>
<Quote>
<Currency>NcName1</Currency>
<QuoteDate>QuoteDate1</QuoteDate>
<FreightTotal>1</FreightTotal>
<ServicesTotal>1</ServicesTotal>
<Total>1</Total>
<CarrierName>NcName1</CarrierName>
</Quote>
</Quotes>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论