Before I start my ob XML::Twig pitch... ;--)
There are a couple of modules on CPAN that are specifically designed to process record-oriented XML:
- XML::RAX, RAX is described in RAX, an XML Database API.
With XML::RAX you just go through your document, one record at a time:while ( $rec = $R->readRecord()) { print "Phone = ".$rec->getField('Phone')."\n"; }. Note that this works only if each record is "flat" (each element within the record is a single value)
- XML::SAX::Machines also has a record mode, which looks suspiciously like what XML::wig does... except it's SAX-based and integrates nicely with other SAX processing. I haven't tried this module (yet) but it looks interesting.
Finally XML::Twig was designed especially for this kind of problem. You can easily get rid of part of the document after you are done processing it: you can set a twig_handler for each ArgusFlowRecord, which will call a sub that has access to everything inside the element, then call purge or flush (if you need to output the updated element) and get your memory back./,/p>
See the tutorial, section 4.3 is what you are looking for (n ote that since I wrote the tutorial I added a field method that is equivalent to first_child->text but looks nicer.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.