Changing SimpleXML data within a loop - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Changing SimpleXML data within a loop (/showthread.php?tid=33325) |
Changing SimpleXML data within a loop - El Forum - 08-22-2010 [eluser]anthrt[/eluser] I'm doing some work with the Discogs API trying to serialize the data of a release for use in another local application. A release on Discogs is something like a music album, so it contains the tracklisting, artists, remixers etc. Here is a sample track row returned from the API, I'm using SimpleXML to parse the XML document. Code: <track> Which more simply looks like this: Ramirez And Tajada - Listen To The Drums On this, I need to class the artist "Tajada" as a guest on this track, however, the "role" is defined in the previous artist's XML row: Code: <name>Ramirez</name> How can I sort through the rows to 'swap' these around? I can't figure out a way how to automatically detect the "join" in the previous artist element, and do some logic based on it within the next iteration of the loop. I hope everyone can understand what i'm trying to get at, as I can't figure this out! Regards |