0

Can i use default perl (say Strawberry perl 5.20 v) to build xml and populate its content with mine data? Or it is better to use modules from cpan like libXML or SimpleXML ? Are any useful modules default by installation ?

2 Answers 2

2

Strawberry Perl is bundled with many useful prebuilt modules, including the excellent XML::LibXML and XML::Twig

I recommend XML::Writer for creating XML documents from scratch, but unfortunately it isn't on the list of bundled modules. However App::cpanminus is there, which means you can add to your collection of utilities with

cpanm XML::Writer

from the command line

1
  • Having used Activestate extensively, it's useful to know Strawberry ships with those.
    – Sobrique
    Jun 22, 2015 at 12:22
1

This is a recommendation question, so typically that's offtopic. However I will draw your attention to this from XML::Simple.

The use of this module in new code is discouraged. Other modules are available which provide more straightforward and consistent interfaces. In particular, XML::LibXML is highly recommended.

Depending on the task, different libraries are 'good'. XML::LibXML or XML::Twig are solid choices. XML::Simple isn't - it's prone to making bad code.

Above all though - you should DEFINITELY use a parser, because whilst XML looks a bit like plain text, it isn't - there are some actually quite strict rules about what is - and isn't - OK in XML, and there are some semantically identical snippets of XML that have completely different formatting.

This question is my attempt at assembling XML with XML::Twig.

Assembling XML in Perl

You will probably have to install either of these modules. But don't worry. Installing modules is a Good Thing, and one of the reasons why Perl is so good.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.