Sorting an XML list...
Posted: Fri Sep 02, 2011 4:00 pm
Help! I'm still pretty new at this php malarky so please be gentle...
Basically what I'm trying to do is to load an XML file structured like so...
I'm loading the XML file using the following method...
..and then writing the XML file back out to the server using the following...
Basically what I need to do is to sort the XML list using the 'start date' element. I've spend a good few hours googling various php code solutions but none of them seem to work. Anyone got a very simple solution that will crack this?! Help!!!!!
Basically what I'm trying to do is to load an XML file structured like so...
Code: Select all
<?xml version="1.0"?>
<training>
<course>
<startdate>2011-29-02</startdate>
<displaydate>29th February - 5th March</displaydate>
<name>CCR Normoxic</name>
<location>Malta</location>
</course>
<course>
<startdate>2011-29-04</startdate>
<displaydate>5th - 12th April</displaydate>
<name>CCR Normoxic</name>
<location>Malta</location>
</course>
<course>
<startdate>2011-29-03</startdate>
<displaydate>14th - 21st March</displaydate>
<name>Rebreather</name>
<location>Gran Canaria</location>
</course>
<course>
<startdate>2011-29-07</startdate>
<displaydate>18th - 25th July</displaydate>
<name>CCR Hypoxic</name>
<location>Malta</location>
</course>
</training>
Code: Select all
$training = new SimpleXMLElement('training.xml', null, true);
Code: Select all
$training->asXML('training.xml');