It would be much better to have the XML structured the way in which you said, but when you are receiving the data from a client and this is how their database is set up with over 15,000 shops,it would be a slight pain in the a to try and restructure everything.

I already worked out how to split the categories, but I want it to loop through each shop node and extract the categories information and add them to the same array.. any ideas?