The following code:
// Get sub category:
$xml = simplexml_load_string($update_booking_info->XML);
Gives me this: (All correct so far)
SimpleXMLElement Object
(
[@attributes] => Array
(
[sub_category_id] => 1
)
[LocationClass] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Type] => LocationIdentification
)
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => SimpleXMLElement Object
(
)
[VZeroQuestionsCollectionID] => SimpleXMLElement Object
(
)
[Name] => FromLocation
[Address] => Some address 1
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Type] => LocationIdentification
)
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => SimpleXMLElement Object
(
)
[VZeroQuestionsCollectionID] => SimpleXMLElement Object
(
)
[Name] => ToLocation
[Address] => Some Address 2
)
)
[DateTimeInfo] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Type] => DateTime
)
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => 3842
[VZeroQuestionsCollectionID] => 916
[Name] => PickupDate
[DateTime] => 2014-03-28 00:59:08
)
[TextField] => Array
(
[0] => SimpleXMLElement Object
(
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => 3846
[VZeroQuestionsCollectionID] => 916
[Name] => Cellphone
[Text] => 1234567891
)
[1] => SimpleXMLElement Object
(
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => 3843
[VZeroQuestionsCollectionID] => 916
[Name] => ContactName
[Text] => John Smit
)
[2] => SimpleXMLElement Object
(
[Lat] => 0
[Long] => 0
[VZeroQuestionLifeTimeKey] => 3848
[VZeroQuestionsCollectionID] => 916
[Name] => NumberPassengers
[Text] => 2
)
)
)
I now need to query the array above to get the Address/DateTime/Text value based on the Name within that node:
so if I was looking for say the DateTime value from DateTimeInfo I need to query the Name (PickupDate) which will be unique and get the related property. I already have a variable which will tell me what the "value" property for that node is (like DateTime, Text etc) so I just need to know how to query the XML to get the correct node and find the values within that one. I am also happy to use another reader if need be.
Any ideas?