Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
<top_level>
<name>test case</name>
<junk>just some more tags</junk>
<sub_level_1>
<element name="attr1">
<value format="inches">121</value>
<modifier>add</modifier>
</element>
<element name="attr2">
<value format="yards">1.5</value>
<modifier>sub</modifier>
</element>
</sub_level_1>
</top_level>
In using XML::DT I can format it such that I get each value in the hash, but I am looking to reformat the hash via XML::DT.
%handler = ( -default => sub{$c},
-type => {name => 'MAP',
junk => 'MAP',
sub_level_1 => 'SEQ',
element => 'MAP'
});
returns
$VAR = { name => 'test case',
junk => 'just some more tags',
sub_level_1 => start_array # submit form rejects bracket
{value => '121', modifier => 'add'},
{value => '1.5', modifier => 'sub'}
end_array}
what I would like to return is: (notice attributes are used as hash index)
$VAR = { name => 'test case',
junk => 'just some more tags',
sub_level_1 => { attr1 => {value => '121', modifier => 'add'},
attr2 => {value => '1.5', modifier => 'sub'}}}
Now I know this has to do with the declaring a sub
function but I am having difficult with the pointers.
%handler = ( -default => sub{$c},
-type => {name => 'MAP',
junk => 'MAP',
element => 'MAP'
},
sub_level_1 => sub { split('\n', $c) }
# returns list of pointers
# but need hash indexed by attribute name
# This is where I need HELP - Please
);
Thanks
Joe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::DT and hashes/pointers
by mirod (Canon) on Sep 19, 2000 at 21:36 UTC | |
|
Re: XML::DT and hashes/pointers
by Anonymous Monk on Sep 20, 2000 at 17:26 UTC |