Solved

the best xml parser module

Posted on 2003-10-23
3
202 Views
Last Modified: 2010-03-05
I want to use perl module to parse xml files. But not sure which one is the best and most stable. Someone told me that xmltwig is good. But I haven't used it before and wonder whether there is something better than that if I want a tree structure output. just like DOM.
0
Comment
Question by:dong9968
3 Comments
 
LVL 2

Accepted Solution

by:
ultimatemike earned 50 total points
ID: 9608255
It depends on what you're trying to do.  What type of parsing will you be doing? Just extracting a few values, or will it be necessary to traverse entire tries?

You mentioned XML::Twig, which is quite powerful.  I haven't used it myself, but there are numerous tutorials on it.  I recall seeing one on the O'Reilly website, although I can't remember the link.


XML::Simple allows you to read in XML files as nested hashes of references, which can be very useful if you're only extracting a few values, and what you want out of the XML isn't that complicated. I've used it myself and found it quite handy.

http://search.cpan.org/~grantm/XML-Simple-2.09/lib/XML/Simple.pm


And XML::Parser is a SAX based parser.  It requires a bit more work than the previous too to set up, as you need to set up event handlers for all of the tags encountered in parsing.  As long as you don't need to walk a tree when parsing and can handle all of the tags as they come, this should be quite powerful, and very light on memory.

http://search.cpan.org/~msergeant/XML-Parser-2.34/Parser.pm



And finally, if you do need DOM, theres XML::DOM (which is built on top of XML::Parser).  I haven't used it myself, but it can be found here:
http://search.cpan.org/~enno/libxml-enno-1.02/lib/XML/DOM.pm
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10030527
Nothing has happened on this question in over 2 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by ultimatemike.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question