2

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?

1
  • That depends on how simple you mean. An example might help. Commented Apr 28, 2010 at 12:27

2 Answers 2

2

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/

Sign up to request clarification or add additional context in comments.

Comments

1

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

2 Comments

A 2001 article. Have things not moved on a bit since then?
Not with the XML standard, so these methods will still generate valid XML - agreed, there may be easier ways if your particular installation has kept up with all the pre-requisite libraries for some of the (arguably) simpler options that have come about since then. The article does use an example of generating XML from a hash, per the OP's request, though

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.