Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Outputting a hash as XML

by Anonymous Monk
on Aug 12, 2015 at 23:32 UTC ( [id://1138355]=note: print w/replies, xml ) Need Help??


in reply to Re: Outputting a hash as XML
in thread Outputting a hash as XML

I found the create_element function really useful, have added a slight modification to the above function to handle keys that are in turn array references
sub create_element { my $gi = shift; my $data = shift; my $node = XML::Twig::Elt->new($gi); if (ref $data eq "HASH") { while (my ($key, $value) = each(%$data)) { if (ref $value eq "ARRAY") { for my $i (@$value) { createXmlTree($key, $i)->paste(last_child => $node); } } else { createXmlTree($key, $value)->paste(last_child => $node); } } } else { $node->set_text($data); } $node; };
Thanks Joseph

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found