xml内容听起来很成功,但是我无法从内容中获取所需的信息
发布Xml
$xml = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://ws.ups.com/wsByTrackingNumber">
<soapenv:Body>
<GetTransactionsByTrackingNumber_V1 xmlns="http://ws.ups.com/wsByTrackingNumber/">
<SessionID>'.strip_tags($response2).'</SessionID>
<InformationLevel>1</InformationLevel>
<TrackingNumber>XXXXXX996800071633</TrackingNumber>
</GetTransactionsByTrackingNumber_V1>
</soapenv:Body>
</soapenv:Envelope>';
我通过提交我的信息成功返回了结果。但是我无法获得所需的xml标记。
响应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>
<GetTransactionsByTrackingNumber_V1Response xmlns="http://ws.ups.com.tr/wsPaketIslemSorgulamaEng/">
<GetTransactionsByTrackingNumber_V1Result>
<PackageTransaction>
<TrackingNumber>XXXXX996800071633</TrackingNumber>
<ProcessTimeStamp>20191204-181757</ProcessTimeStamp>
<OperationBranchName>CITY HUB</OperationBranchName>
<StatusCode>31</StatusCode>
<ExceptionCode>--</ExceptionCode>
<ProcessDescription1>PICKED UP PER CUSTOMER CALL</ProcessDescription1>
<ProcessDescription2 />
<RecordId>3838837092</RecordId>
<InformationLevel>1</InformationLevel>
<ErrorCode>0</ErrorCode>
<ErrorDefinition />
</PackageTransaction>
<PackageTransaction>
<TrackingNumber>XXXXX996800071633 </TrackingNumber>
<ProcessTimeStamp>20191204-210346</ProcessTimeStamp>
<OperationBranchName>CITY HUB</OperationBranchName>
<StatusCode>12</StatusCode>
<ExceptionCode>--</ExceptionCode>
<ProcessDescription1>SCAN INTO A CONTAINER</ProcessDescription1>
<ProcessDescription2>B89160315Z7</ProcessDescription2>
<RecordId>3838985579</RecordId>
<InformationLevel>1</InformationLevel>
<ErrorCode>0</ErrorCode>
<ErrorDefinition />
</PackageTransaction>
</GetTransactionsByTrackingNumber_V1Result>
</GetTransactionsByTrackingNumber_V1Response>
</soap:Body>
</soap:Envelope>
卷曲Xml帖子
$url = "http://ws.ups.com/QueryPackageInfo/wsQueryPackagesInfo.asmx?op=GetTransactionsByTrackingNumber_V1";
//Initiate cURL
$curl = curl_init($url);
curl_setopt ($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
$info = curl_getinfo($curl);
if(curl_errno($curl)){
$data['curlhata'] = curl_error($curl);
}
$xml = simplexml_load_string($result);
print_r($xml);
foreach($xml as $xmls){
print_r($xmls);
}
我需要返回PackageTransaction
标签,但我做不到