- simplexml_load_string: documentation ( source)
<?php
$xml='<workout_file>
<workout>
<FreeRide Duration="300" Power="1.3"/>
<SteadyState Duration="300" Power="0.55"/>
<FreeRide Duration="10" Power="1.2"/>
<SteadyState Duration="180" Power="0.55"/>
<FreeRide Duration="10" Power="1.1"/>
<SteadyState Duration="120" Power="0.55"/>
</workout>
</workout_file>';
$xml=simplexml_load_string($xml);
$count = 0;
foreach($xml->workout->children() as $node ){
$type = $node->getName();
echo $type." position: ".$count."<br>";
$count++;
//Get Attributes
echo "Duration: ".$node['Duration']."<br>";
echo "Power: ".$node['Power']."<br>";
}