You are here:  » Max ExecutionTime 90 sec


Max ExecutionTime 90 sec

Submitted by derek on Mon, 2005-12-05 05:33 in

I need to parse a 150MB XML file and the parser gives me a fatal error saying:

Maximum exection time of 90 second exceeded in ..../MagicParser.php

Is there any way I can fix this or how can I resolve this issue ?

thanks,

Derek

Submitted by support on Mon, 2005-12-05 10:06

Hi Derek,

To enable unlimited execution time use the following code at the top of your script:

<?php
  set_time_limit
(0);
  
// ... rest of script ...
?>

This is a PHP function; not part of the Magic Parser library.

With a file the size that you are talking about it would really help to use a format string in the optional 3rd parameter to the parse function.

If you want to figure out what the format string is for your document the best way is to first write a test script that just calls MagicParser_getFormat() and displays the result; something like:

<?php
  set_time_limit
(0);
  require(
"MagicParser.php");
  
$filename "/path/to/file.xml";
  
$format_string MagicParser_getFormat($filename);
  print 
$format_string;
?>

Hope this helps!

Submitted by derek on Mon, 2005-12-05 23:50

so, let's say the format is like this.

<whatever>
  <XXX>
    <yyy>asdfd</yyy>
  </XXX>
  <XXX>
    <yyy>sdfdfg</yyy>
  </XXX>
<whatever>

So, the string parameters is (xml,WHATEVER/WHATEVER) ?

and what other parameters I can set , except this
set_time_limit ? is there like a manual ?

thanks,

Derek

Submitted by support on Tue, 2005-12-06 07:22

Hi Derek,

In the case of your example XML, the format string would be "XML|WHATEVER/XXX/". This is because the information you are interested in is within each XXX tag, but you can't just provide "XXX" on its own, you need to specify the path to it within the tree, which is why the "WHATEVER" is needed also.

> and what other parameters I can set , except this set_time_limit ? is there like a manual ?

set_time_limit() is a PHP function, it is nothing specifically to do with Magic Parser. There are additional script control functions that you may find useful:

http://uk.php.net/manual/en/ref.info.php

Submitted by derek on Wed, 2005-12-07 01:05

So, do you think I can use it as like a boolean thing ?

for example,
inside WHATEVER, I have
<WWW>asdf</WWW>

but I only interested in content within
<XXX>asdfasd</XXX>, can I achieve this by putting
XML|WHATEVER/XXX as an extra parameters (format string) ?

thanks,

Derek

Submitted by support on Wed, 2005-12-07 07:24

There shouldn't be any need to modify your format string just because you are only interested in the contents of one field in each record. The Format String tells the parser which part of your XML document repeats rather than which part you are specifically interested.

Your code is then responsible for isolating any information you actually want from each record within your myRecordHandler function. I hope this makes sense. If you want to post more complete XML examples you can use the <code> tags within the forum so that your XML will be formatted properly. It will also help to include the full XML tree to the parts that you are interested in so that I can help determine what format string values you need to be using.