Connecting Tech Pros Worldwide Forums | Help | Site Map

Parsing XML File - PHP out of memory?

bmichel@gmail.com
Guest
 
Posts: n/a
#1: Jan 18 '07
Hey,

What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content

The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.

Someone has any ideas how I can solve this problem?


bmichel@gmail.com
Guest
 
Posts: n/a
#2: Jan 18 '07

re: Parsing XML File - PHP out of memory?


I tried modifying the value of the max_execution_time in my php.ini.
I also tried the set_time_limit() function.
Both ways no success...

I'm sure the script is not getting stuck somewhere, because I manually
divided the XML file into several files. And then, I ran the script for
each of those files and it worked.


David Gillen wrote:
Quote:
bmichel@gmail.com said:
Quote:
Hey,

What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content

The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.

Someone has any ideas how I can solve this problem?
Check the max_execution_time in your php.ini
You can override it with set_time_limit(), http://www.php.net/set_time_limit
That'll allow your script to run for longer, test on a smaller file to ensure
your script isn't getting stuck in a loop somewhere and is doing what it
should.
>
D
--
Erwin Moller
Guest
 
Posts: n/a
#3: Jan 18 '07

re: Parsing XML File - PHP out of memory?


bmichel@gmail.com wrote:
Quote:
I tried modifying the value of the max_execution_time in my php.ini.
I also tried the set_time_limit() function.
Both ways no success...
>
I'm sure the script is not getting stuck somewhere, because I manually
divided the XML file into several files. And then, I ran the script for
each of those files and it worked.
Answer: It destroys the natural order of the conversation.
Question: Why is that?
Answer: Topposting
Question: What is the most annoying thing on usenet.


That aside, siply make some debugoutput in your script, and use ob_flush()
to make sure it reaches the browser before the timeout happens.

eg: During parsing, simply echo "Entering bla di bla with value XXX";

That way you can actually see if your script is doing what you think it is
doing.

Regards,
Erwin Moller
Quote:
>
>
David Gillen wrote:
Quote:
>bmichel@gmail.com said:
Quote:
Hey,
>
What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content
>
The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.
>
Someone has any ideas how I can solve this problem?
>
>Check the max_execution_time in your php.ini
>You can override it with set_time_limit(),
>http://www.php.net/set_time_limit That'll allow your script to run for
>longer, test on a smaller file to ensure your script isn't getting stuck
>in a loop somewhere and is doing what it should.
>>
>D
>--
bmichel@gmail.com
Guest
 
Posts: n/a
#4: Jan 18 '07

re: Parsing XML File - PHP out of memory?


Tried it, doesn't work for me.

What might be the problem is the limit of the size of a variable in
PHP. How can I change that?


Erwin Moller wrote:
Quote:
bmichel@gmail.com wrote:
>
Quote:
I tried modifying the value of the max_execution_time in my php.ini.
I also tried the set_time_limit() function.
Both ways no success...

I'm sure the script is not getting stuck somewhere, because I manually
divided the XML file into several files. And then, I ran the script for
each of those files and it worked.
>
Answer: It destroys the natural order of the conversation.
Question: Why is that?
Answer: Topposting
Question: What is the most annoying thing on usenet.
>
>
That aside, siply make some debugoutput in your script, and use ob_flush()
to make sure it reaches the browser before the timeout happens.
>
eg: During parsing, simply echo "Entering bla di bla with value XXX";
>
That way you can actually see if your script is doing what you think it is
doing.
>
Regards,
Erwin Moller
>
Quote:


David Gillen wrote:
Quote:
bmichel@gmail.com said:
Hey,

What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content

The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.

Someone has any ideas how I can solve this problem?

Check the max_execution_time in your php.ini
You can override it with set_time_limit(),
http://www.php.net/set_time_limit That'll allow your script to run for
longer, test on a smaller file to ensure your script isn't getting stuck
in a loop somewhere and is doing what it should.
>
D
--
Erwin Moller
Guest
 
Posts: n/a
#5: Jan 19 '07

re: Parsing XML File - PHP out of memory?


bmichel@gmail.com wrote:
Quote:
Tried it, doesn't work for me.
>
What might be the problem is the limit of the size of a variable in
PHP. How can I change that?
Hi,

1) Stop topposting please. (See my former posting if you wonder why)
2) What the %$#$ does 'Tried it, doesn't work for me.' mean?

If you don't bother to spend the time to clearly write down WHAT does work
and WHAT doesn't, why should we put time into YOUR problem?
We are not getting paid for this man...

Erwin Moller



Quote:
>
>
Erwin Moller wrote:
Quote:
>bmichel@gmail.com wrote:
>>
Quote:
I tried modifying the value of the max_execution_time in my php.ini.
I also tried the set_time_limit() function.
Both ways no success...
>
I'm sure the script is not getting stuck somewhere, because I manually
divided the XML file into several files. And then, I ran the script for
each of those files and it worked.
>>
>Answer: It destroys the natural order of the conversation.
>Question: Why is that?
>Answer: Topposting
>Question: What is the most annoying thing on usenet.
>>
>>
>That aside, siply make some debugoutput in your script, and use
>ob_flush() to make sure it reaches the browser before the timeout
>happens.
>>
>eg: During parsing, simply echo "Entering bla di bla with value XXX";
>>
>That way you can actually see if your script is doing what you think it
>is doing.
>>
>Regards,
>Erwin Moller
>>
Quote:
>
>
David Gillen wrote:
>bmichel@gmail.com said:
Hey,
>
What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content
>
The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.
>
Someone has any ideas how I can solve this problem?
>
>Check the max_execution_time in your php.ini
>You can override it with set_time_limit(),
>http://www.php.net/set_time_limit That'll allow your script to run for
>longer, test on a smaller file to ensure your script isn't getting
>stuck in a loop somewhere and is doing what it should.
>>
>D
>--
Andy Hassall
Guest
 
Posts: n/a
#6: Jan 20 '07

re: Parsing XML File - PHP out of memory?


On 18 Jan 2007 06:32:14 -0800, bmichel@gmail.com wrote:
Quote:
>What I'm doing is the following:
>- Load XML data a file
>- Parsing the XML data
>- Printing some parsed content
>
>The problem is that the script execution is stopping before all the
>content is parsed and printed.
>Maybe the PHP is out of memory after a while. That would make sense
>since the XML file is about 2 MB.
>
>Someone has any ideas how I can solve this problem?
(1) Raise the PHP memory_limit parameter and/or max_execution_time (as posted
by others), depending on what error you get (you didn't post an error).

(2) Change the script to use less memory, e.g. by using a stream-based parser
such as expat - see http://php.net/xml - instead of loading the entire file
into memory then parsing it.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Closed Thread