[英]How to parse this soap xml response without soap client php
I have to parse this xml and retrieve Username
and Password
value. 我必须解析此xml并检索Username
和Password
值。
<?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>
<ProcessResponse
xmlns="http://api.securecrmsite.com/">
<ProcessResult>
<RequestID>5666290</RequestID>
<PrimaryKeyID>0</PrimaryKeyID>
<Success>true</Success>
<Message>Process completed. Found 1 records.</Message>
<Records>1</Records>
<ProcessData>
<xs:schema id="NewDataSet"
xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Results">
<xs:complexType>
<xs:sequence>
<xs:element name="CustomerID" type="xs:int" minOccurs="0" />
<xs:element name="Username" type="xs:string" minOccurs="0" />
<xs:element name="Password" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet
xmlns="">
<Results diffgr:id="Results1" msdata:rowOrder="0">
<CustomerID>2465266</CustomerID>
<Username>tamimanother1</Username>
<Password>4565AA</Password>
</Results>
</NewDataSet>
</diffgr:diffgram>
</ProcessData>
<XmlRequest>&lt;soap:Envelope
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
xmlns:soap=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt;&lt;soap:Body&gt;&lt;Process
xmlns=&quot;http://api.securecrmsite.com/&quot;&gt;&lt;Credentials&gt;&lt;CompanyKey&gt;3785&lt;/CompanyKey&gt;&lt;APIKey&gt;7ca9d84b-e7c9-4d19-aae1-218d109eab6f&lt;/APIKey&gt;&lt;/Credentials&gt;&lt;ProcessName&gt;CustomerInsert&lt;/ProcessName&gt;&lt;Parameters&gt;&lt;ApiParams&gt;&lt;Name&gt;FirstName&lt;/Name&gt;&lt;Value&gt;tamim&lt;/Value&gt;&lt;/ApiParams&gt;&lt;ApiParams&gt;&lt;Name&gt;LastName&lt;/Name&gt;&lt;Value&gt;another&lt;/Value&gt;&lt;/ApiParams&gt;&lt;ApiParams&gt;&lt;Name&gt;Email&lt;/Name&gt;&lt;Value&gt;test@test.com&lt;/Value&gt;&lt;/ApiParams&gt;&lt;/Parameters&gt;&lt;/Process&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
</XmlRequest>
</ProcessResult>
</ProcessResponse>
</soap:Body>
</soap:Envelope>
I have tried with this -> 我已经尝试过->
```
$xml = str_ireplace(['SOAP-ENV:', 'SOAP:'], '', $xml);
$data = simplexml_load_string($xml);
print_r($data->Body->ProcessResponse->NewDataSet);
```
If you want xpath then try this 如果您想要xpath,请尝试这个
concat(//Results/Username,"|",//Results/Password)
result String='tamimanother1|4565AA'
结果String='tamimanother1|4565AA'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.