Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best XML parser for Perl?

Tags:

xml

perl

libxml2

I have tried many of the Perl XML Parsers. I was quite interested in the Sablotron Parser, but it is such a pain to install on a Windows box. Currently I have started using XML::LibXML and XML::LibXSLT both of which seem to do everything I need.

They seem to be quite standard as well. Are there any better XML Parsers to use than this?

like image 713
Xetius Avatar asked Jan 28 '09 10:01

Xetius


People also ask

Which parser is used in XML?

The XMLNS parser preserves all parts of an XML document, including white space formatting. You can create all XML constructs when constructing an output message. The XMLNSC and MRM parsers build compact message trees that use fewer syntax elements than the XMLNS parser for attributes and simple elements.

What are the two types of XML parser?

In PHP there are two major types of XML parsers: Tree-Based Parsers. Event-Based Parsers.

Which parser is best in parsing in large size documents Why?

DOM Parser is faster than SAX Parser. Best for the larger sizes of files.


2 Answers

I think you are using a pretty good one. XML::LibXML, Matt Sergeant and Christian Glahn's Perl interface to Daniel Velliard's libxml2 is one of the faster XML Parsers that I know of.

like image 75
mmcdole Avatar answered Sep 29 '22 11:09

mmcdole


It really depends on your needs, as people have said. To parse XML files that were ~100Mb in size (gene annotations from TAIR, 1 file per chromosome), I used mirod's XML::Twig module, which lets you set callbacks to parse the elements that interest you, presenting each sub-document as an XML::Simple tree. It combines the benefits of a SAX parser (scanning the file as a stream) with a DOM parser (working more easily with the interesting pieces).

like image 33
Dotan Dimet Avatar answered Sep 29 '22 11:09

Dotan Dimet