如何解析,迭代或转换为数组以下结果?
这是通过SOAP收到的确切结果。 最后我需要将这些项目放入数组中。
<xs:schema xmlns:mstns="http://tempuri.org/PriceListDS.xsd" xmlns="http://tempuri.org/PriceListDS.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="PriceListDS" targetNamespace="http://tempuri.org/PriceListDS.xsd" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="PriceListDS" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="PriceList">
<xs:complexType>
<xs:sequence>
<xs:element name="itemcode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="itemname" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Price" type="xs:decimal" minOccurs="0"/>
<xs:element name="OrigPrice" type="xs:decimal" minOccurs="0"/>
<xs:element name="Multiple" msdata:ReadOnly="true" type="xs:int" minOccurs="0"/>
<xs:element name="vat" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//mstns:PriceList"/>
<xs:field xpath="mstns:itemcode"/>
</xs:unique>
</xs:element>
</xs:schema>
[请注意,下面的片段已与上面的XSD组合在一起。为清楚起见分开。]
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<PriceListDS xmlns="http://tempuri.org/PriceListDS.xsd">
<PriceList diffgr:id="PriceList1" msdata:rowOrder="0">
<itemcode>
.........
我使用PHP获取响应
try{
$options = array(
'trace' =>1,
'encoding' => 'UTF-8',
'cache_wsdl' => WSDL_CACHE_NONE
);
$client = new SoapClient($url, $options );
$response = $client->GetPrice($request);
结果实际上是一个对象
stdClass Object
(
[GetPriceResult] => stdClass Object
(
[any] => xsd_result
)
)
尝试使用SimpleXML
$xml_doc = simplexml_load_string($response->GetPriceResult->any);
但我得到了Warning: simplexml_load_string(): Entity: line 1: parser error