Reading values of a multi-dimensional array populated by xpath

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
    • SubNodeItem4
    • SubNodeItem5

I am able to retrieve the value of any of the SubNode values by using the following syntax:


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:


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.

Leave a Reply


Hire Me
Follow Me!
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.