I've been asked to Parse XML using PHP printing both the values of attributes of each node & path info so wondered if any of you gurus could assist.
My colleague doesnt know what fields he finally wants mapped until he sees all the results so I thought it would be a good idea to pass the XML file and then he could pick and choose.
To then aid me in providing what he wants it would be good to get the path beside each output, so I'm looking for something like this: NOTE: this is not the XML I'll be using, he doesnt have that yet so the solution needs to be very generic and look after whatever is chucked at it.
The XML can and will go to many child levels, values and atributes etc.
<song dateplayed="2011-07-24 19:40:26">
<title>I left my heart on Europa</title>
<artist>Ship of Nomads</artist>
<song dateplayed="2011-07-24 19:27:42">
<song dateplayed="2011-07-24 19:23:50">
<artist>Jewitt K. Sheppard</artist>
So with this basically iterate the whole thing and produce something like:
2011-07-24 19:40:26 | song['dateplayed']
I left my heart on Europa | song->title
Ship of Nomads | song->artist
2011-07-24 19:27:42 | song['dateplayed']
Oh Ganymede | song->title
Beefachanga | song->artist
2011-07-24 19:23:50 | song['dateplayed']
Kallichore | song->title
Jewitt K. Sheppard | song->artist