I'm reading through an xml file to get data. The xml looks like this:
<packet>
<item>
<timestamp>0</timestamp>
<<id>10</id>
<id>14</id>
<id>2</id>
<id>7</id>
<id>6</id>
</item>
<item>
<timestamp>1</timestamp>
<id>4</id>
<id>4</id>
<id>8</id>
<id>3</id>
<id>2</id>
<id>12</id>
</item>
...
</packet>
I cut the xml file because its long. The number of id within each timestamp varies. I already got the code to read through the xml file
<?php
if(file_exists('myfile.xml'))
{
$xml = simplexml_load_file ("myfile.xml");
}
else {
exit ('Could not load the file...');
}
foreach($xml->item as $item)
{
echo $item->timestamp.'<br>';
{
foreach($item->id as $id)
{
echo $id.' ';
}
echo '<br>';
echo '<br>';
}
}
And the result is something like this
0
10 14 2 7 6
1
4 4 8 3 2 12
I just don't know how to got about plotting this in php in such a way that the timestamp is on the x-axis and the id gets plotted on the y-axis
Aucun commentaire:
Enregistrer un commentaire