XML Parsing and Generating

acme on 2007-03-14T11:12:50

There are a ton of XML libraries on the CPAN but XML isn't as simple as you think. For parsing and generating XML I use and recommend XML::LibXML which wraps a fast and robust C library. For some good examples read the Perl Advent Calendar on XML::LibXML and XML::LibXML - An XML::Parser Alternative.


I use templates for generating XML

grantm on 2007-03-14T20:33:22

I agree that XML::LibXML is an excellent module for parsing XML. I tend to steer people towards it when they start dreaming up new features for XML::Simple.

When generating XML, I almost always use either the Template Toolkit or HTML::Mason.

Re:I use templates for generating XML

vek on 2007-03-15T06:09:46

In the true spirit of overkill, I found myself using XML::LibXML *and* XML::Simple in the same program today.

I needed to validate some XML against a schema so XML::LibXML::Schema helped nicely. But after validation, the data structure provided by XMLin() was *exactly* what I needed so I thought bugger it I'll just use both ;-)

XML::LibXML and XML::Simple for teh win!

XML::SAX

Alias on 2007-03-15T06:35:06

I dunno exactly why but whenever I need to do non-trivial XML I keep finding myself going back to XML::SAX.

XML::LibXML *and* XML::Simple

grantm on 2007-03-15T23:04:35

Actually that pretty much sums up the recommended use case for XML::Simple. If what it gives you is exactly what you need then use it. Otherwise use XML::LibXML.

Re:XML::LibXML *and* XML::Simple

grantm on 2007-03-15T23:05:42

Oops, I thought I was replying to vek's comment