mscharrer has asked for the wisdom of the Perl Monks concerning the following question:
I went through the XML::Simple documentation but I didn't find anything suitable. The 'KeyAttr' option does actually create the wanted hash structure but only for one A and one B class div because the class isn't a key attribute here.
Could anyone with more XP with XML::Simple point me out the right option(s). Also maybe an other XML module must be used for that.
Thanks in advance, and sorry if it's really simple and I just oversaw it.
My simple test script so far is:
#!/usr/bin/perl use strict; use warnings; use XML::Simple; my $filename = shift or die "Usage: decode <filename>\n"; my $xmlin; open ($xmlin, '<', $filename) or die "Error: Can't open input file!\n" +; my $ref = XMLin( $xmlin, # TODO: Add correct option ); use Data::Dumper; print Dumper $ref; __END__
The XHTML content:
<div id="main"> <div class="A"> ... </div> <div class="A"> ... </div> <div class="A"> ... </div> <div class="B"> ... </div> <div class="B"> ... </div> <div class="B"> ... </div> </div>
The hash structure I want:
$VAR1 = { 'div' => { 'A' => [ { .. }, { .. }, { .. }, ], 'B' => [ { .. }, { .. }, { .. }, ] } };
|
|---|