I have an xml structure :
<Pages> <!--This is the root node-->
<Home>
<url>...</url>
<menu>
<item>Help</item>
<item>About</item>
<item>Contact</item>
</menu>
</Home>
<Help>
<url>...</url>
<menu> <!--i need to select this if its parent(Help) is listed in Home/menu/item above-->
<item>Business Help</item>
<item>Web Help</item>
<item>Tour Help</item>
</menu>
</Help>
<About>
<url>...</url>
<menu> <!--And Or select this if its parent(About) is listed in Home/menu/item above-->
<item>About us</item>
<item>About our food</item>
</menu>
</About>
<Contact>
<url>...</url>
<menu> <!--And Or select this if its listed in Home/menu/item above-->
...
and so on...
...
</menu>
</Contact>
</Pages>
i issued an xpath expression to fetch all menu node in the document, whose parent name appeared (or is listed) in any sibling of the parent in the same document. two different xpressions have been tryed:
$PageName = 'Home';
"./*/*[name() = 'menu' and ../../$this->PageName/menu/item/. = name(..)]";
and
"./*[name() = (following-sibling::$this->PageName | preceding-sibling::$this->PageName)/menu/*]/menu";
in either case, the result i got after var_dump() was:
'menu' =>
array (size=1)
'item' =>
array (size=3)
0 => string 'Business Help' (length=13)
1 => string 'Web Help' (length=8)
2 => string 'Tour Help' (length=9)
//instead of something like :
'menu' =>
array (size=2)
'item' =>
array (size=3)
0 => string 'Business Help' (length=13)
1 => string 'Web Help' (length=8)
2 => string 'Tour Help' (length=9)
'item' =>
array (size=2)
0 => string 'About us' (length=8)
1 => string 'About our food' (length=14)
...
why is xpath returning just one menu array (Help/menu) while refusing to copy About/menu, Contact/menu, and so on. or am i doing the wrong thing ? any help will be greatly appreciated. thaks.