即使浏览了太多帖子,我也找不到在 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
其他信息。非常感谢您提供的任何帮助。