SimpleXMLElement Object
(
[@attributes] => Array
(
[VER] => 2.00
[NOTE] =>
[FOR] =>
[ENCODE] => 0
)
[OFFER] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[OPERATOR] => TEST
[SPO] => HRK-639-TIV-HRV
[DATE] => 20140430
[COUNTRY] => HRV
[TOUR] => HRV: Дубровник из Харькова через Тиват 7,14 ночей (а/к МАУ)
[TRC] => 735
[TOURTYPE] => Отдых
[TRTC] => 2
[ADL] => 1
[CHD] => 0
[INF] => 0
[CURRENCY] => EUR
)
[HOTELS] => SimpleXMLElement Object
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[BEG] => 0
[END] => -1
[NAME] => FARAON ADRIATIQ HOTEL
[HTC] => 28128
[STAR] => 3*
[ROOM] => COMFORT ROOM SEA VIEW
[RMC] => 9583
[PLACE] => SGL
[PLC] => 7238
[MEAL] => BB
[MLC] => 4
[CITY] => Trpanj
[CNT] => 1
)
)
)
...
<code>
Не могу получить данные с блока [HOTELS], подозреваю что должно быть так <code>$xml->OFFER[$i]->HOTELS[0]->attributes()->NAME</code>, но к сожалению нет( Возможно кто то работал с Travel xml?
Большое спасибо за советы)
Tip to get a real array of all attributes of a node (not SimpleXML's object acting like an array)<?php //- $node is a SimpleXMLElement object $atts_object = $node->attributes(); //- get all attributes, this is not a real array $atts_array = (array) $atts_object; //- typecast to an array //- grab the value of '@attributes' key, which contains the array your after $atts_array = $atts_array['@attributes']; var_dump($atts_object); //- outputs object(SimpleXMLElement)[19] //- public '@attributes' => ... var_dump($atts_array); //- outputs array (size=11) ... ?>
Hope this helps!
echo (string)$xml->OFFER[$i]->HOTELS[0]->attributes()->NAME;