I’ve got this xml file
<notes>
<note>
<title>Dag 1</title>
<details>
<detail>Test A</detail>
<detail>Test B</detail>
</details>
</note>
<note>
<title>Dag 2</title>
<details>
<detail>Test C</detail>
<detail>Test D</detail>
<detail>Test E</detail>
</details>
</note>
</notes>
Which I’m reading with this simplexml php script:
<?php
// load XML file
$xml = simplexml_load_file('test.xml') or die ("Unable to load XML!");
// access XML data
foreach($xml->note as $note){
echo "<h2>" . $note->title ."</h2>\
";
foreach($note->details->detail as $detail){
echo $detail."<br />\
";
}
}
?>
Which works fine. But I was wondering: is it also possible to read an xml file without specifying the nodes? I’ll try to explain I want it to open the xml file. But then I want it to read the nodes in the order they appear in the xml file. Without naming each node. So it has to figure out that upon opening the main ‘notes’ node, the first node is ‘note’, then upon every ‘note’ it has to figure out that it has to read ‘title’ and ‘details’ (and ‘detail’ nodes inside ‘details’). All without naming the nodes. In the end it has to list the node values in the order they appear in the xml file.
Do I make myself clear ? And is that possible?