BIG problem.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've to manage quite very large XML files. I tough it was an SQL error, but
I've figured out the problem is somewhere else.

I've a big structure, with lot of datas and pictures encoded in every XML
files. Sometimes, I've error, and the script crashes.

Here is the code:

   $xml_parser = xml_parser_create();
   xml_set_element_handler($xml_parser, "startElement", "endElement");
   xml_set_character_data_handler($xml_parser, "FDataHandler");

   while ($data = fread($fp, 4096)) {
    if (!xml_parse($xml_parser, $data, feof($fp))) {
     die(sprintf("XML error: %s at line %d",
     rename($XMLPath.$file, $XMLPath.$failpath.$file); //move file in error
     $OK = false;

Now, this part of the code takes 4096 bytes and parse datas:

Now, if the 4096 bytes are in the middle of the file, I get big problems. In
my case, the data2 is cutted somewhere in the middle
The script should only work when the </datastart> is reached, isn'it ??? but
how to do so ? The actual file is 5MB large, with lot of pictures in it.


Re: BIG problem.

*** Bob Bedford wrote/escribió (Mon, 17 Jan 2005 18:05:43 +0100):
Quoted text here. Click to load it

Quoted text here. Click to load it

Does you XML parser consider the case where elements are larger than 4096

-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions

Re: BIG problem.

Quoted text here. Click to load it

Actually not, because I don't know how to do so.
I do have this:

function endElement($parser, $name)
 case 'datastart': //commencer à enregistrer les données importantes pour
les véhicules
   //save in DB. Get the error here sometimes
I didn't manage to check if the elements were larger than 4096 as I tough
the save in DB code was only executed when the closing tag was reached. If
I'm wrong, what's the solution ?


Site Timeline