Re: XML parser error ..

From: Date: Wed, 22 Nov 2006 14:49:54 +0000
Subject: Re: XML parser error ..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-245043@lists.php.net to get a copy of this message
Delete the initial extra line in:
$xml_data = <<<EOF <?xml version="1.0"?>
The XML Parser expects the XML document to start with a valid XML statement, which in your file is: <?xml version="1.0"?> but yours starts with an newline. $xml_data = <<<EOF //newline <?xml version="1.0"?> onewaylife wrote:
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 : - <html> <head> <basefont face="Arial"> </head> <body> <?php // cdata handler function characterDataHandler($parser, $data) {
      echo $data . "<p>"; 
} 
// PI handler function PIHandler($parser, $target, $data) {
      // if php code, execute it 
      if (strtolower($target) == "php") 
      {
           eval($data); 
      } 
      // otherwise just print it 
      else 
      {
            echo "PI found: [$target] $data"; 
      } 
} 
// XML data $xml_data = <<<EOF <?xml version="1.0"?> <article>
      <header>insert slug here</header> 
      <body>insert body here</body> 
      <footer><?php print "Copyright UNoHoo Inc," . date("Y", mktime());
?></footer>   
</article> 
EOF; 
// initialize parser $xml_parser = xml_parser_create(); // set cdata handler xml_set_character_data_handler($xml_parser, "characterDataHandler"); // set PI handler xml_set_processing_instruction_handler($xml_parser, "PIHandler"); if (!xml_parse($xml_parser, $xml_data)) {
      die("XML parser error: " . 
xml_error_string(xml_get_error_code($xml_parser))); 
} 
// all done, clean up! xml_parser_free($xml_parser); ?> </body> </html> it give this output " XML parser error: Reserved XML Name" even i created two more php files but it give same message as out put. I am unable to understand why its come. Please help me out. onewaylife
-- _____________________ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/

« previous php.general (#245043) next »