There are several PHP tools for working with XML.
You may want to take a look at PHP DOM:
I have never worked with DOM, but I have worked with PHP XML. DOM will turn the XML data into a PHP object, so you can iterate through that, but if that doesn’t work out you can try PHP XML:
With PHP XML, PHP reads through the XML data, and each time it hits a different type of data, it will call a specified function that you made. For example, every time it hits a start tag, it will call your start tag function and tell you the name of the tag and its attributes. When you hit a content tag, it will call your content function and give it the data that is in the content. You then have to keep track, usually with an array, of where in the xml document you are, IE (pretend its html data):
$doc = ‘html’;
$doc = ‘body’;
$doc = ‘p’;
$doc = ‘span’;
You would have a variable that says what level you’re at (then find the current tag with $doc[$lvl]), and in the start tag function you would increment that level variable and add the next item to the array, and in the end tag function you would decrement the level variable.