in reply to Predefining complex data structures?
But, since you asked, how about this:$VAR1 = { 'requirement' => [ { 'contactname' => 'Joe Average', 'content' => 'A power cord.' }, { 'contactnumber' => '555-1212', 'contactname' => 'Jane Smith', 'content' => 'A node name' } ] };
This produced the following data structure for me:use strict; use XML::Simple; my $data = do {local $/;<DATA>}; my $xml = XMLin($data,forcearray=>1); my $new; for my $req (@{$xml->{requirement}}) { my %temp; $temp{text} = delete $req->{content}; $temp{attributes} = [%$req]; push @{$new->{requirements}}, {%temp}; } __DATA__ <xml> <requirement contactname="Joe Average">A power cord.</requirement> <requirement contactname="Jane Smith" contactnumber="555-1212">A node +name</requirement> </xml>
UPDATE:$VAR1 = { 'requirements' => [ { 'text' => 'A power cord.', 'attributes' => [ 'contactname', 'Joe Average' ] }, { 'text' => 'A node name', 'attributes' => [ 'contactnumber', '555-1212', 'contactname', 'Jane Smith' ] } ] };
But that probably will not work for you. :($VAR1 = { 'method' => [ { 'object' => [ 'Properties', 'Do not use option Foo', 'Server Name', 'OK' ], 'content' => [ 'Open up the ', ' page. Then uncheck the ', ' checkbox. Under ', ' enter ', ' and then hit ' ], 'input' => [ 'www.example.com' ] } ] };
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ionizor) Re: Predefining complex data structures?
by Ionizor (Pilgrim) on Jul 12, 2002 at 15:19 UTC |