0

I am php beginner and try run some example code from http://www.w3schools.com/php/php_xml_dom.asp but I keep running into this error:

AH01071: Got error 'PHP message: PHP Parse error: syntax error, unexpected '$item' (T_VARIABLE) in test.php on line 8\n'

Can somebody help me resolving the error? This is code (test.php) I am using:

<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("note.xml");

$x = $xmlDoc->documentElement;
foreach ($x->childNodes AS $item) 
{
  print $item->nodeName . " = " . $item->nodeValue . "<br>";
}

?>
Johan
  • 1
  • 1
  • Can't reproduce the error. – Rizier123 Aug 21 '16 at 12:29
  • Perhaps you deleted a dot in your code, which you have put in your question? Or you got rid of a double quote? Check your code against the w3schools code, character by character. – KIKO Software Aug 21 '16 at 12:30
  • I solved the issue by changing character set from ANSI to UTF-8 in Notepad++. This revealed two hidden charaters before 'print'. After removing those the code works. – Johan Aug 21 '16 at 12:45

0 Answers0