【发布时间】:2012-05-31 21:16:21
【问题描述】:
我正在从事一个网络服务集成项目。现在,使用 cURL 方法传递请求并获得 XML 响应。我没有保存 XML 响应文件,而是在我的页面中回显了 XML 响应(认为它会节省服务器响应时间)。现在我在我的页面中得到了这样的 XML 响应,
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" >
<SOAP-ENV:Body>
<CreateShipmentReply xmlns="http://www.parcelforce.net/ws/ship/v5">
<CompletedShipmentInfo>
<Status>ALLOCATED</Status>
<CompletedShipments>
<CompletedShipment>
<ShipmentNumber>MK0030912</ShipmentNumber>
</CompletedShipment>
</CompletedShipments>
<RequestedShipment>
<DepartmentId>1</DepartmentId>
<ShipmentType>DELIVERY</ShipmentType>
<ContractNumber>P664383</ContractNumber>
<ServiceCode>SUP</ServiceCode>
<ShippingDate>2012-05-25</ShippingDate>
<RecipientContact>
<BusinessName>BUSINESS NAME</BusinessName>
为了将 XML 中的数据保存到我的数据库/表中,我需要从节点解析它。我有从保存的文件中解析 XML 的代码,但在回显的 XML 响应中找不到相同的解决方案。如何从回显的 XML 响应中读取数据。
需要帮助。提前致谢。
【问题讨论】:
-
为什么不使用 PHP SOAP 类集合 (php.net/manual/en/book.soap.php)?
-
如果你的xml文件不是很大使用SimpleXml,否则你可以使用DOM XML
-
@webbandit SOAP 类不适用于我正在使用的 wsdl,因此我选择了 cURL。
标签: php xml web-services xml-parsing echo