Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

the best xml parser module

Posted on 2003-10-23
3
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
ultimatemike earned 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

636 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