OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Problem with XML processing under PHP (code don't runs)

[ Lists Home | Date Index | Thread Index ]

Hi,
I read a tutorial about this topic.
I have copied the code, and copy into a file.
Here is the PHP code:
---------------------------------------------

<?php
// data file
$file = "library.xml";

// initialize parser
$xml_parser = xml_parser_create();

// set callback functions
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

// open XML file
if (!($fp = fopen($file, "r")))
{
    die("Cannot locate XML data file: $file");
}

// read and parse data
while ($data = fread($fp, 4096))
{
    // error handler
 if (!xml_parse($xml_parser, $data, feof($fp)))
 {
    die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
    }
}

// clean up
xml_parser_free($xml_parser);

?>

---------------------------------------------

and here the XML file:

---------------------------------------------

<?xml version="1.0"?>

<library>
 <book>
  <title>Hannibal</title>
  <author>Thomas Harris</author>
  <genre>Suspense</genre>
  <pages>564</pages>
  <price>8.99</price>
  <rating>4</rating>
 </book>

 <book>
  <title>Run</title>
  <author>Douglas E. Winter</author>
  <genre>Thriller</genre>
  <pages>390</pages>
  <price>7.49</price>
  <rating>5</rating>
 </book>

 <book>
  <title>The Lord Of The Rings</title>
  <author>J. R. R. Tolkien</author>
  <genre>Fantasy</genre>
  <pages>3489</pages>
  <price>10.99</price>
  <rating>5</rating>
 </book>

</library>

---------------------------------------------

When I test the script with the Omnicron WebServer,
I get these Error messages:

---------------------------------------------

Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in F:\WebServer\HTDOCS\test.
php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler startelement() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler characterdata() in
F:\WebServer\HTDOCS\test.php on line 22
Warning: Unable to call handler endelement() in F:\WebServer\HTDOCS\test.php
on line 22

---------------------------------------------

mmaaannnyyy warnings, isn't it ;) ?
Why the code don't runs. I know Omnicron isn't a good WebServer, but Iam no
proffessionel,
and i want only to test my scripts, before uploading it to my hoster.
Please help me :)

cya






_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS