Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在PHP中循环/解析SOAP响应以获得所有结果_Php_Soap_Soapui - Fatal编程技术网

如何在PHP中循环/解析SOAP响应以获得所有结果

如何在PHP中循环/解析SOAP响应以获得所有结果,php,soap,soapui,Php,Soap,Soapui,我不熟悉PHP和SOAP,并尝试在PHP代码中获取值SOAP响应。 使用下面的代码,我能够得到一组响应,但不是全部三个 if (count($triphistory->TripHistoryList) > 0) { $trip_history_data = $triphistory->TripHistoryList[0]; 下面是SOAP响应,我必须获得“TripHistoryList”的所有值 <ns2:TripHistoryList>

我不熟悉PHP和SOAP,并尝试在PHP代码中获取值SOAP响应。
使用下面的代码,我能够得到一组响应,但不是全部三个

if (count($triphistory->TripHistoryList) > 0) {
           $trip_history_data = $triphistory->TripHistoryList[0];
下面是SOAP响应,我必须获得“TripHistoryList”的所有值

<ns2:TripHistoryList>
        <ns2:TagSerialNumber>6501099999999</ns2:TagSerialNumber>
        <ns2:PlateNumber>ABCD</ns2:PlateNumber>
        <ns2:PlateState>VA</ns2:PlateState>
        <ns2:TxnTime>2018-07-20T23:22:30.080-04:00</ns2:TxnTime>
        <ns2:PlazaId>495010</ns2:PlazaId>
        <ns2:Zone>1</ns2:Zone>
        <ns2:HovSW>H</ns2:HovSW>
        <ns2:HovNom>H</ns2:HovNom>
     </ns2:TripHistoryList>
     <ns2:TripHistoryList>
        <ns2:TagSerialNumber>6501099999999</ns2:TagSerialNumber>
        <ns2:PlateNumber>XYZA</ns2:PlateNumber>
        <ns2:PlateState>VA</ns2:PlateState>
        <ns2:TxnTime>2018-07-20T23:22:30.080-04:00</ns2:TxnTime>
        <ns2:PlazaId>951010</ns2:PlazaId>
        <ns2:Zone>1</ns2:Zone>
        <ns2:HovSW>H</ns2:HovSW>
        <ns2:HovNom>H</ns2:HovNom>
     </ns2:TripHistoryList>
     <ns2:TripHistoryList>
        <ns2:TagSerialNumber>6501099999999</ns2:TagSerialNumber>
        <ns2:PlateNumber>UGHF</ns2:PlateNumber>
        <ns2:PlateState>VA</ns2:PlateState>
        <ns2:TxnTime>2018-07-20T23:22:30.080-04:00</ns2:TxnTime>
        <ns2:PlazaId>951010</ns2:PlazaId>
        <ns2:Zone>1</ns2:Zone>
        <ns2:HovSW>T</ns2:HovSW>
        <ns2:HovNom>T</ns2:HovNom>
     </ns2:TripHistoryList>  

6501099999999
ABCD
弗吉尼亚州
2018-07-20T23:22:30.080-04:00
495010
1.
H
H
6501099999999
XYZA
弗吉尼亚州
2018-07-20T23:22:30.080-04:00
951010
1.
H
H
6501099999999
UGHF
弗吉尼亚州
2018-07-20T23:22:30.080-04:00
951010
1.
T
T
仅供参考:我显示的输出如下。谢谢你的帮助

<tbody>
        <tr>
            <th width="20%">Tag Serial Number</th>
            <th width="20%">Plate_Number</th>
            <th width="20%">REAR PLATE JURISDICTION</th>
            <th width="20%">TXN TIMESTAMP</th>
            <th width="20%">PLAZA ID</th>
            <th width="20%">ZONE LANE</th>
            <th width="20%">LINK ID</th>
            <th width="20%">HOV SW</th>
            <th width="20%">HOV NOM Due</th>
        </tr>
        <tr>
               <td width="20%"><?php e($trip_history_data->TagSerialNumber); ?></td>
              <td width="20%"><?php e($trip_history_data->PlateNumber); ?></td>
              <td width="20%"><?php e($trip_history_data->PlateState); ?></td>
               <td width="20%"><?php e($trip_history_data->TxnTime); ?></td>
              <td width="20%"><?php e($trip_history_data->PlazaId); ?></td>
              <td width="20%"><?php e($trip_history_data->Zone); ?></td>
             <td width="20%"><?php e($trip_history_data->PlazaId); ?></td>
             <td width="20%"><?php e($trip_history_data->HovSW); ?></td>
              <td width="20%"><?php e($trip_history_data->HovNom); ?></td>
 </tr>

标签序列号
车牌号
后板管辖权
TXN时间戳
广场ID
区域车道
链接ID
霍夫西南
霍夫诺姆酒店

您可以将代码更改为

<?php 
          foreach($trip_history_data as $data) {
?>
<tr>
               <td width="20%"><?php e($data->TagSerialNumber); ?></td>
              <td width="20%"><?php e($data->PlateNumber); ?></td>
              <td width="20%"><?php e($data->PlateState); ?></td>
               <td width="20%"><?php e($data->TxnTime); ?></td>
              <td width="20%"><?php e($data->PlazaId); ?></td>
              <td width="20%"><?php e($data->Zone); ?></td>
             <td width="20%"><?php e($data->PlazaId); ?></td>
             <td width="20%"><?php e($data->HovSW); ?></td>
              <td width="20%"><?php e($data->HovNom); ?></td>
 </tr>
<?php } ?>


是否需要将此更改为$trip_history_data=$triphistory->TripHistoryList[0];因为0索引给出了第一个结果,所以我需要删除那里的索引吗?太好了。你能选择我的答案作为答案吗