【发布时间】:2013-02-02 16:48:38
【问题描述】:
即使浏览了太多帖子,我也找不到在 PHP 中解析这个 XML 的方法:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SingleResponse xmlns="http://content.host.com">
<ContentCafe DateTime="2013-02-18T04:31:16.1619171-05:00">
<RequestItems UserID="abcdefg" Password="hijklmnop">
<RequestItem>
<Key Type="ISBN" Original="9780002571838">9780002571838</Key>
<Content>ProductDetail</Content>
<ProductItems>
<ProductItem ID="8714731">
<ISBN>9780002571838</ISBN>
<Title>Memoirs</Title>
<Author>Rees-Mogg, William</Author>
<Source Code="BTB">B&T Books</Source>
<Product Code="BOOK">Book</Product>
<Supplier Code="HARPE">HarperCollins</Supplier>
</ProductItem>
</ProductItems>
</RequestItem>
</RequestItems>
</ContentCafe>
</SingleResponse>
</soap:Body>
</soap:Envelope>
我来到这里:
$xml = new SimpleXMLElement($xml);
但不知道如何继续阅读Title、Author 和其他信息。非常感谢您提供的任何帮助。
【问题讨论】:
-
你能用
xml_parse_into_struct()吗? -
@Pekka웃 - 我看过那篇文章,但不太明白
$res = $client->SoapFunction(array('param1'=>'value','param2'=>'value'));的步骤。感谢您的帮助。