Wiggins d'Anconia said:
> Scott Taylor wrote:
>> Hello,
>>
>> I have an XML file that I need to import to a database,
<snip>
>>
>> What module should I use for something simple like the following data?
>
> I would start with XML::Simple until you need more.
>
> use XML::Simple;
>
> my $xs = new XML::Simple;
> my $ref = $xs->XMLin('test.xml');
>
> use Data::Dumper;
> print Dumper($ref);
OK. That looks really kewl. Now how do I loop through this ...
$VAR1 = {
'vid' => '29751',
'desc' => 'Ignition On',
'date' => '20050517235927',
'drv' => {},
'j1587' => {
'data' => [
{
'mid' => {
'desc' => 'Engine #1',
'val' => '128'
},
'pid' => {
'desc' => 'Total Vehicle Distance',
'val' => '245'
},
'min' => '0',
'max' => '1060771',
'val' => '1060771'
},
......
{
'mid' => {
'desc' => 'Engine #1',
'val' => '128'
},
'pid' => {
'desc' => 'Trip Fuel',
'val' => '182'
},
'min' => '0',
'max' => '0',
'val' => '0'
}
]
},
'eid' => '0',
'event' => 'I'
};
... to pump out lines of data to my SQL statement.
I'll need to end up with something like:
qw($vid,$eid,$event,$desc
,$date,$mid_desc,$mid_val
,$pid_desc,$pid_val,$min,$max,$val)
for each line of data. (or whatever works)
I think I'm just lost at the nested hash (if that's what it's called)
thingy, and how to work with it. :|
Cheers.
--
Scott
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>