Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

XML::DOM Alternative

by PerlingTheUK (Hermit)
on Jun 21, 2005 at 22:19 UTC ( #468836=perlquestion: print w/replies, xml ) Need Help??

PerlingTheUK has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks,
I have used XML::DOM for some XML File manipulation. Usually this was a open, alter and save job and XML::DOM is most perfect for this. But however it is not implemented very good for reducing memory and the 40 MByte files I need to alter just exhaust all available memory. Are there any similar models that are implemented natively and offer a conveniently easy interface?


Replies are listed 'Best First'.
Re: XML::DOM Alternative
by Joost (Canon) on Jun 21, 2005 at 22:34 UTC
Re: XML::DOM Alternative
by fauria (Deacon) on Jun 21, 2005 at 22:59 UTC
    You can choose XML::SAX as an alternative API. Here you can find a brief discussion on using SAX or DOM.
Re: XML::DOM Alternative
by grantm (Parson) on Jun 22, 2005 at 08:11 UTC

    As noted above, XML::Twig might be a good choice. For something a bit closer to what you're used to, XML::LibXML is worth a look. It uses the DOM API, but since the parsing and DOM building are implemented in C the performance and memory footprint are much better than a Perl DOM. LibXML also supports XPath which is the first thing you need to learn if you're trying to manipulate XML without it. See also the Perl XML FAQ.

Re: XML::DOM Alternative
by srdst13 (Pilgrim) on Jun 22, 2005 at 10:54 UTC
    If you aren't yet convinced on the merits of XML::Twig, note that you can parse chunks of the code using any module you like by passing the "twig" to a second parser. For example, you can use Twig to pull out each section of a file then use XML::DOM to parse and operate on it. Finally, there is XML::Twig::XPath which combines Twig and XPath for a very powerful tool for quickly and with minimal memory footprint.

      I have a combo of: use XML::Parser; use XML::SimpleObject; which works very well via an object-oriented interface.
Re: XML::DOM Alternative
by PerlingTheUK (Hermit) on Jun 23, 2005 at 12:02 UTC
    Thank you for all your replies. I will consider XML::Twig. I am sorry I did not reply any earlier but my Wireless router dd not like the heat wave we have here in the midlands at the moment.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://468836]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2022-11-29 01:22 GMT
Find Nodes?
    Voting Booth?