Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > In deep complex XML

Reply
Thread Tools

In deep complex XML

 
 
sow
Guest
Posts: n/a
 
      07-22-2007
To professional geeks of perl.
I need to get values from complicated xml which is below:

$VAR1 = {
'report_params' => {
'customer_code' => 'name',
'customer_id' => '123',
'account_details' => [
{
'account_code' => 'account01',
'state_code' => 'DELETED',
'related_ani' => {
'state_code' =>
'DELETED',
'phone_number' =>
'123456',
'object_id' => '12',
'subscription' => [
{

'valid_to' => '2007-07-17T13:42:46',

'valid_from' => '2007-07-16T19:17:05',

'service_type_code' => 'VoIP',

'service_code' => 'serv01'
},
{

'valid_to' => '2007-07-18T12:15:16',

'session' => [

{

'currency_code' => 'QWE',

'duration' => '0',

'amount' => '0',
},

{

'currency_code' => 'QWE',

'duration' => '1313',

'amount' => '-1.75',
}
],

'valid_from' => '2007-07-17T13:43:23',

'service_type_code' => 'VoIP',

'service_code' => 'serv02'
},
{

'valid_to' => '2007-07-18T12:51:19',

'valid_from' => '2007-07-18T12:47:51',

'service_type_code' => 'VoIP',

'service_code' => 'serv03'
}
]
},
'created_date' => '2007-07-16T19:02:12'
},
{
'account_code' => 'account02',
'state_code' => 'ENABLED',
'related_ani' => {
'state_code' =>
'ENABLED',
'state_change_date' =>
'2007-07-18T12:56:33',
'phone_number' =>
'123456',
'object_id' => '13',
'subscription' => [
{

'session' => [

{

'currency_code' => 'QWE',

'duration' => '0',

'amount' => '0',
},

{

'currency_code' => 'QWE',

'duration' => '150',

'amount' => '-1.975',
},

{

'currency_code' => 'SEC',

'duration' => '101',

'amount' => '-101',
},

{

'currency_code' => 'SEC',

'duration' => '616',

'amount' => '-616',
}
],

'valid_from' => '2007-07-18T12:56:33',

'service_type_code' => 'VoIP',

'service_code' => 'serv04'
}
},
'created_date' => '2007-07-18T12:52:47'
}
],
};

and script in perl:

#!/usr/bin/perl
use XML::Simple;
$xml = new XML::Simple;
$data = $xml->XMLin($ARGV[0],
KeyAttr => {account_details => 'account_code',subscription =>
'service_code',session => 'currency_code'},
ForceArray => 1,
);

foreach $e (@{$data->{account_details}->{account02}->{related_ani}-
>{subscription}->{serv04}->{session}->{QWE}})

{
printf "value %20s\n",$e->{amount};
}

and I've error:
Pseudo-hashes are deprecated at ./script line 9.
No such pseudo-hash field "account02" at ./billing2 line 9.

Please write any advice. Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
In deep complex XML sow Perl Misc 5 07-23-2007 03:27 PM
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
Deep Freeze In Deep Trouble johntangelo@gmail.com Computer Security 3 10-25-2005 11:49 PM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM



Advertisments