Swati
Swati

Reputation: 21

How can I generate an XML using Perl and XSLT?

I want to generate an XML file using Perl and XSLT. Is it possible to achieve this by updating the XSLT dynamically by uusing values from a hash?

Or is there any better solution for wirting a simple XML file using Perl?

Upvotes: 2

Views: 241

Answers (2)

Rowland Shaw
Rowland Shaw

Reputation: 38130

XSLT is not for generating XML, it is merely for transforming XML. There's a comparison of the XML interfaces available to Perl on O'Reily's XML site

Upvotes: 1

DVK
DVK

Reputation: 129363

The answer is "It depends" but generally "Simple" XML can be printed directly from Perl data structiures using XML::Simple module's XMLOut.

For more complicated use XML::Writer.

You can read more on handling of XML in Perl (including printing it) in Perl and XML O'Reilly book - for examples see Chapter 3 online (XML::Writer part): http://oreilly.com/catalog/perlxml/chapter/ch03.html

Also look at Perl-XML FAQ: http://perl-xml.sourceforge.net/faq/

Upvotes: 2

Related Questions