Reading values of a multi-dimensional array populated by xpath

leemaize

New Member
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
    • SubNodeItemListSubListItemSubItemProperty1
    • SubItemProperty2
    • SubItemProperty3
  • SubItemList
    • SubItemProperty1
    • SubItemProperty2
    • SubItemProperty3
[*]SubNodeItem4[*]SubNodeItem5I am able to retrieve the value of any of the SubNode values by using the following syntax:\[code\]$val=$XML[$i]->SubNodeItem1;\[/code\]however, I can not for the life of me figure out how to retrieve the values of \[code\]SubListItemProperty\[/code\]. I figured this would be the logical syntax:\[code\]$SubItemPropVal=$XML[$i]->SubNodeItemList->SubListItem[$i]->SubItemProperty1;\[/code\]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 \[code\]"Trying to get property of non-object"\[/code\] error when I run the code. I'm pretty sure that's the indication that I'm not pointing the node correctly.
 
Back
Top