i am creating a php file which will parse an XML file and output it to the screen. the xml file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<linkCollection>
<linkGroup id="Photoshop">
<linkItem id="2">
<title>blairdee.info</title>
<description>This is the second link</description>
<url>http://www.blairdee.info</url>
</linkItem>
<linkItem id="4">
<title>Fandango</title>
<description>This is the fourth Link</description>
<url>http://www.fandango.com</url>
</linkItem>
<linkItem id="1">
<title>Google</title>
<description>This is the first link</description>
<url>http://www.google.com</url>
</linkItem>
<linkItem id="3">
<title>Microsoft Windows 7 Website</title>
<description>This is the third link</description>
<url>http://www.microsoft.com/windows7</url>
</linkItem>
</linkGroup>
</linkCollection>
i want to be able to output each <linkitem> to the screen, but order it by linkItem's id attribute.
I have an idea in mind but please tell me if there is a simpler/better way.
i was thinking to create a two dimensional array where each element contained an associative array with elements to contain the info from the XML (title, description, url, id).
but once i have it in that array, would it be possible to sort the first dimension of the array by the id key of the second dimension?
or am i going about this all wrong??
could use some advice here.