in reply to perl Data structure to XML
The first thing that I observe from looking at your Perl data-structure, vs. the resulting XML output, is that the two are not the same. For example:
would correspond to a list of three nodes, each having three attributes apiece. Any XML-writer would immediately produce such an XML output.members => [ { name => "george", role => "husband", age => 41, }, { name => "jane", role => "wife", age => 39, }, { name => "elroy", role => "kid", age => 9, },
Given that this is not what you want, you should transform your hash so that its structure does match what you want. In place of three hashes, create three arrays. (None of the elements in your desired output are to have any “attributes” at all.) Consult the Perldoc to see what the data structure needs to look like. Once you have done this, and have done it in the most simple-and-obvious way possible, you can hand this data structure to an XML-writer and get your XML.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl Data structure to XML
by Hosen1989 (Scribe) on May 29, 2015 at 15:08 UTC |