In deep complex XML

Discussion in 'Perl Misc' started by sow, Jul 22, 2007.

  1. sow

    sow Guest

    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.
    sow, Jul 22, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.amnet.net.au
    Replies:
    1
    Views:
    557
    =?UTF-8?b?TMSByrtpZSBUZWNoaWU=?=
    Apr 13, 2004
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    733
    Stanimir Stamenkov
    Oct 25, 2005
  3. Robert Mark Bram
    Replies:
    0
    Views:
    671
    Robert Mark Bram
    Feb 4, 2007
  4. Kottiyath

    How complex is complex?

    Kottiyath, Mar 18, 2009, in forum: Python
    Replies:
    22
    Views:
    737
  5. sow

    In deep complex XML

    sow, Jul 22, 2007, in forum: Perl Misc
    Replies:
    5
    Views:
    103
    Mumia W.
    Jul 23, 2007
Loading...

Share This Page