I am a bit of a newbie to PHP and I'm not sure what I'm missing here. I have an multidimensional array that I've created from an XML file using XPath. I'm able to move through the array and retrieve most all values but I am getting stuck on one section.
Example of XML structure:
- MasterNode
- SubNodeItem1
- SubNodeItem2
- SubNodeItem3
- SubNodeItemList
- SubListItem
- SubItemProperty1
- SubItemProperty2
- SubItemProperty3
- SubItemList
- SubItemProperty1
- SubItemProperty2
- SubItemProperty3
- SubListItem
- SubNodeItem4
- SubNodeItem5
I am able to retrieve the value of any of the SubNode values by using the following syntax:
$val=$XML[$i]->SubNodeItem1; however, I can not for the life of me figure out how to retrieve the values of SubListItemProperty.
I figured this would be the logical syntax:
$SubItemPropVal=$XML[$i]->SubNodeItemList->SubListItem[$i]->SubItemProperty1; I have searched other forums and topics related to PHP multi arrays and have not been able to find the proper way to do this.
I am getting a "Trying to get property of non-object" error when I run the code. I'm pretty sure that's the indication that I'm not pointing the node correctly.
->) at all. Please providevar_dumpof your object in the question, it will be much more informative.