Solved

the best xml parser module

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Uploading Binary Data using Perl 5 83
rename outfile before writing 2 71
ppm conversion to curl on a module install 8 80
File Find regex problem 4 60
I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
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…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

895 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now