Here's the sample xml:
And here's the php code:
So why, when I view the page, do I get this error:
Parse error: parse error, expecting `','' or `';'' in /home/httpd/vhosts/csnradio.com/www/test/2.php on line 6
I'm really clueless as to why this would happen because there are tutorials all over the place that are quite similar to this.
Thanks in advance!
Code:
<?xml version="1.0" encoding="UTF-8"?> <menu> <entry> <action> Test </action> <title> Test Menu Item 1 </title> </entry> <entry> <action> Test 2 </action> <title> Test Menu Item 2 </title> </entry> </menu>
Code:
<?php $dom = new DOMDocument(); $dom->load("menu.xml"); $menu = new domxpath($dom); foreach($menu->query("//menu/entry") as $entry) { echo "Action is: " . $menu->query('.//action',$entry)->item(0)->nodeValue; echo "Title is: " . $menu->query('.//title',$entry)->item(0)->nodeValue; } ?>
Parse error: parse error, expecting `','' or `';'' in /home/httpd/vhosts/csnradio.com/www/test/2.php on line 6
I'm really clueless as to why this would happen because there are tutorials all over the place that are quite similar to this.
Thanks in advance!
Comment