From: Rob Dixon <[EMAIL PROTECTED]> > Seth wrote: > > I have an existing xml file that I need to display. Perl was > > suggested a good way to do that. > > > > I am using XML::Simple. None of the examples use the format that I > > have. > > > > Here is an example of what I am dealing with: > > > > <config> > > <param name="SequenceNumber">66</param> > > <param name="T1">6</param> > > <param name="T3">6</param> > > <param name="T4">540</param> > > <param name="DownloadDate">11-28-07</param> > > </config> > > > > I can use Dumper to see that it has been loaded but can't figure out > > how to navigate the structure. > > Any help would be great. > > IMO XML::Simple is anything but simple to use, but the program below may > help. I can't suggest any more without knowing what sort of output you > need.
XML::Simple is very simple to use provided the XML is sensible and you use ForceArray and KeyAttr well. OTOH, XML::Rules gives you more power to convert the extracted data into the structure you need: use strict; use warnings; use XML::Rules; my $xml = <<XML; <config> <param name="SequenceNumber">66</param> <param name="T1">6</param> <param name="T3">6</param> <param name="T4">540</param> <param name="DownloadDate">11-28-07</param> </config> XML my $parser = XML::Rules->new( rules => [ param => sub {$_[1]->{name} => $_[1]->{_content}}, config => 'pass no content', ], ); my $tree = $parser->parse($xml); use Data::Dumper; print Dumper($tree); print "The download date was $tree->{DownloadDate}\n"; Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/