Solved

the best xml parser module

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

758 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