Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to create XML tree from non-XML source

by themage (Friar)
on Sep 08, 2008 at 14:16 UTC ( #709773=note: print w/ replies, xml ) Need Help??


in reply to How to create XML tree from non-XML source

Hi H4,

You can try to use XML::Simple' XMLout as long as you have a perl hash representing the data you want to write to XML.

use XML::Simple qw(XMLout); my $data={book=>[{name=>"test",author=>"H3"},{name=>"test2",author=>"H +4"}]}; print XMLout($data,NoAttr=>1,RootName=>"books");


Comment on Re: How to create XML tree from non-XML source
Download Code
Re^2: How to create XML tree from non-XML source
by H4 (Acolyte) on Sep 08, 2008 at 17:17 UTC
    Thanks for your input. Unfortunately, XML::Simple does not preserve the ordering of subnodes because it uses hashes rather than lists. In your example, there is no way of telling whether <name> or <author> should appear first in the resulting XML. Sorry I forgot to mention that, in my case, order does matter.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://709773]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2015-07-04 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls