Hello everyone,
I have a problem with simple xml and succesive assigning. Well, I will first explain it in very short way, and in the end i will also paste my code.
What I am trying to do is this:
"menus.xml" is my file. It looks approx like this:
<menus>
<en> //stands for english language, there is also a slovenian node
<menu1>//there are also nodes menu2, menu3, menu4
<name>Retrospective</name>
<text>Nocturno lightscapes is a web site of lighting designer ...</text>
<subtitle>
<subname>Projects</subname>
<number>0</number>
<item>
<itemname>Birmingham</itemname>
<number>1</number>
<teaser>Workshop in UK/Light art adorning old factories</teaser>
<action>
<type>project</type>
<param>en_birmingham</param>
</action>
</item>
...
...
...
The file is too long to paste in full here of course.
The php code looks like this:
$menusXML=new SimpleXMLElement(file_get_contents("menus.xml"));
list($currentMenu,)=$menusXML->xpath('//'.$version.'/menu'.$par);
echo $currentMenu->name."</div><div class=\"storycontent\">";
echo $currentMenu->text."<hr/>";
for ($i=0;$i<count($currentMenu)-2;$i++){
list($currentSubtitle,)=$currentMenu->xpath('//subtitle[number='.$i.']');
echo "<h2>".$currentSubtitle->subname."</h2>";
list($currentItem,)=$currentSubtitle->xpath('//item');
}
If I now try to print_r all of 3 $currentXXX varibles i get very a weird result: $currentMenu is ok and so is $currentSubtitle. But $currentItem contains ALL of the 'item' nodes in the whole file (meaning all 4 menus in a file) and not just in the $currentSubtitle. I cannot explain it and cannot find any solution to it.
Thank you in advance
Mitja
p.s. http://www.nocturnolightscapes.com/texten-1.htm. It is an old version which is very cumbersome to edit