@ 2013-07-17T13:27:07Z <?php
$xmlStr = <<<EOD
<response type='5'>
<body order_code='9e8fc2e5-de9b-4dff-a2bd-4175c1063b97' pay_summ='166.37' comiss='7.16' comiss_descr='Комиссия банка: 3 грн + 2,5% от стоимости билета. Сервисный сбор РЦ Министерства транспорта и связи Укр - 18 грн' total_summ='173.53'>
<trip-segment ticket='21П-Н1-1847975-1906' creation_time='19.06.2013 08:57:28' num='1' tot_price='166.37' transporte_type='2' tax='3.00'>
<places>
<place car_num='15' car_type='1040' loc_num='06' />
<place car_num='15' car_type='1040' loc_num='07' />
</places>
</trip-segment>
</body>
</response>
EOD;
$xmlObj = new SimpleXMLElement($xmlStr);
foreach ($xmlObj->{'trip-segment'}->places->place as $place) {
var_dump((string)$place->attributes());
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Warning: Attempt to read property "place" on null in /in/sIARj on line 15
Warning: foreach() argument must be of type array|object, null given in /in/sIARj on line 15
Output for 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.25 , 7.4.27 - 7.4.33 Notice: Trying to get property 'place' of non-object in /in/sIARj on line 15
Warning: Invalid argument supplied for foreach() in /in/sIARj on line 15
Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.1 , 7.3.32 - 7.3.33 , 7.4.26 Warning: Invalid argument supplied for foreach() in /in/sIARj on line 15
Output for 5.2.1 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.36 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 Notice: Trying to get property of non-object in /in/sIARj on line 15
Warning: Invalid argument supplied for foreach() in /in/sIARj on line 15
Output for 5.1.3 - 5.1.6 , 5.2.0 Output for 5.1.2 Warning: Invalid argument supplied for foreach() in /in/sIARj on line 16
Output for 4.3.2 - 4.3.11 , 4.4.0 - 4.4.1 , 4.4.3 - 4.4.9 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/sIARj on line 14
Process exited with code 255 . Output for 4.4.2 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/sIARj on line 15
Process exited with code 255 . Output for 4.3.0 - 4.3.1 Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/sIARj on line 14
preferences:dark mode live preview
257.09 ms | 401 KiB | 375 Q