我正在运行curl请求并返回以下内容:
Array
(
[@attributes] => Array
(
[exp_cid] => 0BqO
)
[REQUEST] => Array
(
[@attributes] => Array
(
[type] => RETURN
[subtype] => CALLBUR
[EXP_ExperianRef] =>
[success] => Y
[timestamp] => Mon, 10 Feb 2014 at 10:28 AM
[id] => 0BqO
)
[MB01] => Array
(
[@attributes] => Array
(
[seq] => 01
)
[DATEOFTRANSACTION] => 20100901
[VRM] => MYREG
[VINCONFIRMATIONFLAG] => 0
[ENGINECAPACITY] => 01360
[DOORPLAN] => 14
[DATEFIRSTREGISTERED] => 20041007
[YEAROFMANUFACTURE] => 2004
[SCRAPPED] => 0
[EXPORTED] => 0
[IMPORTED] => 0
[MAKE] => PEUGEOT
[MODEL] => 307 ENVY 90
[COLOUR] => BLACK
[TRANSMISSION] => MANUAL 5 GEARS
[ENGINENUMBER] => EE
[VINSERIALNUMBER] => VF
[DOORPLANLITERAL] => 5 DOOR HATCHBACK
[MVRISMAKECODE] => L1
[MVRISMODELCODE] => BJJ
[DTPMAKECODE] => L1
[DTPMODELCODE] => 892
[TRANSMISSIONCODE] => M
[GEARS] => 5
[FUEL] => PETROL
[CO2EMISSIONS] => 155
[USEDBEFORE1STREG] => 0
[IMPORTNONEU] => 0
[UKDATEFIRSTREGISTERED] => 20041007
[MAXPERMISSIBLEMASS] => 01639
[MAXNETPOWER] => 085
[MAXTRAILERWEIGHTBRAKED] => 01000
[MAXTRAILERWEIGHTUNBRAKED] => 00620
[SOUNDLVLSTATIONARY] => 079
[SOUNDLEVELENGINESPEED] => 03938
[SOUNDLVLDRIVEBY] => 71
[SEATINGCAPACITY] => 005
[MASSINSERVICE] => 000001245
[MAKEMODEL] => PEUGEOT 307 ENVY 90
)
[MB37] => Array
(
[@attributes] => Array
(
[seq] => 01
)
[V5CDATACOUNT] => 02
[V5CDATAITEMS] => Array
(
[0] => Array
(
[DATE] => 20090825
)
[1] => Array
(
[DATE] => 20041007
)
)
)
)
)
我正在努力获取回报,我尝试了以下但是它没有返回任何内容:
foreach ($xml->REQUEST->MB01 as $requestData) {
echo $requestData;
}
我的另一个问题是取决于它将返回不同的MB块的车辆注册表,如果它们被返回则返回它们。
感谢。
修改
这是我正在运行的完整代码,当它运行时,我得到的只是<这有什么意义吗?
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output[0]['REQUEST']['MB01']['DATEOFTRANSACTION'];
干杯。
答案 0 :(得分:0)
返回是一个数组,而不是一个对象。试试这个:
foreach ($xml['REQUEST']['MB01'] as $requestData) {
if(is_array($requestData) {
print_r($requestData);
} else {
echo $requestData;
}
}