PHP Classes

xml writer class memory consumption

Recommend this page to a friend!

      XML Writer class  >  All threads  >  xml writer class memory consumption  >  (Un) Subscribe thread alerts  
Subject:xml writer class memory consumption
Summary:the xml writer class is a very usefull class, but it uses a lot
Messages:2
Author:c.vlug
Date:2011-05-16 13:49:53
Update:2011-05-16 18:45:50
 

  1. xml writer class memory consumption   Reply   Report abuse  
Picture of c.vlug c.vlug - 2011-05-16 13:49:54
Hi, the xml writer class is a very usefull class, but it uses a lot of memory. I use it for generating an xml sitemap for google. her is some sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<urlset>
<url>
<loc>http://www.somewebsite.nl/</loc>
<priority>1</priority>
<changefreq>daily</changefreq>
<lastmod>2011-05-15T16:38:35+00:00</lastmod>
</url>
<url>
<loc>http://www.somewebsite.nl/index.php</loc>
<priority>1</priority>
<changefreq>daily</changefreq>
<lastmod>2011-05-15T16:38:35+00:00</lastmod>
</url>
</urlset>

when i make an xml documnent with 100.000 url.s the class consumes 400 mb.
i need to make an xml document with 400.000 urls, but i get memory erros, because xml writer class consumes too much memory.
i can't raise php's memory limit moren then 1 or 2 gb
Is there a solution?

regards,
Charles

  2. Re: xml writer class memory consumption   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2011-05-16 18:45:50 - In reply to message 1 from c.vlug
This class was not meant for composing large XML documents. Actually I do not know a solution for composing large XML documents that does not take a lot of memory.

BTW, sitemap files should not have more than 50000 URLs or more than 10MB of size. If you put more, Google Webmaster tools will reject it.

en.wikipedia.org/wiki/Sitemaps