Hi all,

I have to parse an XML file which is ... 1,8 Go large ! My first try was with a simple XML::Parser::Wrapper and of course, it worked perfectly with an example, but ended with 'out of memory' with the real one !!

I then found on the net an article from Kip Hampton from 2001 (on XML.com) which starts with : "The Problem : The XML documents you have to parse are getting too large to load the entire document tree into memory; performance is suffering. The solution : use SAX".
So i drop into XML::SAX, and after a while, understood (i hope) how to code my own handler package with common 'start_element', 'end_element', 'characters', ... methods to do the job.

Again everything is going well with the test file, but when i launch the script with the big one, memory usage starts to reach 100%, then it's the swap usage, and then ... i killed it.

Do you think it could comme from a bad way of coding, or is the module inapropriated, for such a big file ? And if so, would you know a module i could use to read the file inline, without loading all into memory ?
Thanks

julien


In reply to How to Parse Huge XML Files ? by Marsel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.