By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,862 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,862 IT Pros & Developers. It's quick & easy.

XML parser error...

P: 1
Hi all
I am novice in XML. I have just started to creating PHP parser for XML files. I am using SAX.
the file is : -
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <basefont face="Arial">
  4. </head>
  5. <body>
  6. <?php
  7. // cdata handler
  8. function characterDataHandler($parser, $data)
  9. {
  10.       echo $data . "<p>";
  11. }
  12.  
  13. // PI handler
  14. function PIHandler($parser, $target, $data)
  15. {
  16.       // if php code, execute it
  17.       if (strtolower($target) == "php")
  18.       {
  19.            eval($data);
  20.       }
  21.       // otherwise just print it
  22.       else
  23.       {
  24.             echo "PI found: [$target] $data";
  25.       }
  26. }
  27.  
  28. // XML data
  29. $xml_data = <<<EOF
  30. <?xml version="1.0"?>
  31. <article>
  32.       <header>insert slug here</header>
  33.       <body>insert body here</body>
  34.       <footer><?php print "Copyright UNoHoo Inc," . date("Y", mktime()); ?></footer>  
  35. </article>
  36. EOF;
  37.  
  38. // initialize parser
  39. $xml_parser = xml_parser_create();
  40. // set cdata handler
  41. xml_set_character_data_handler($xml_parser, "characterDataHandler");
  42. // set PI handler
  43. xml_set_processing_instruction_handler($xml_parser, "PIHandler");
  44. if (!xml_parse($xml_parser, $xml_data))
  45. {
  46.       die("XML parser error: " .
  47. xml_error_string(xml_get_error_code($xml_parser)));
  48. }
  49.  
  50. // all done, clean up!
  51. xml_parser_free($xml_parser);
  52. ?>
  53. </body>
  54. </html>
Next time read the Posting Guidelines at the top of this forum before you post anything! Especially the part about enclosing shown code within code, php or html tags! - Ronald

it give this output " XML parser error: Reserved XML Name"

I am unable to understand why its come.

Please help me out.
onewaylife
Nov 22 '06 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
I think this SAX question belongs in the XML forum. I will transfer it.

Ronald :cool:
Nov 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.