Solved

the best xml parser module

Posted on 2003-10-23
3
215 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
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…

679 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