in reply to Re^6: Problem in reading parsed xml using XML::Simple
in thread Problem in reading parsed xml using XML::Simple

Try working back up the tree one step at a time to see what's happening:
print Dumper ( $xst->{cmts}{STBDSG} ); then print Dumper ( $xst->{cmts} );
Can you put some sample files up somewhere else - e.g. Dropbox - I could then have a look.

Replies are listed 'Best First'.
Re^8: Problem in reading parsed xml using XML::Simple
by Perl300 (Friar) on Jun 24, 2015 at 19:36 UTC
    Sorry tangent, but I don't have an option for it. The other part of code where fetching data is working as expected is where xml was like:
    <cmts> <name field_name="Name">cts01nsocmo</name> <object field_name="Nemos Object">888</object> <vendor field_name="Vendor">xyz</vendor> </cmts>
    Which was converted as:
    $VAR1 = { 'cmts' => { 'name' => { 'content' => 'cts01nsocmo', 'field_name' => 'Name' }, 'object' => { 'content' => '888', 'field_name' => 'Nemos Object' }, 'vendor' => { 'content' => 'xyz', 'field_name' => 'Vendor' }
    So basically no array and 'content' was there. Where it is not working, xml is like:
    <cmts> <STBDSG> <dsg> <tag1>1</tag1> <tag2>caSystemId</tag2> </dsg> <dsg> <tag1>2</tag1> <tag2>gaSystemId</tag2> </dsg> </STBDSG> </cmts>
    Which was converted as:
    'cmts' => { 'STBDSG' => { 'dsg' => [ { 'tag1' => '1', 'tag2' => 'caSystemId', }, { 'tag1' => '2', 'tag2' => 'gaSystemId', } ] },
    Update: It seems that answer to why $xst->{cmts}{STBDSG}{dsg}[0]{tag1} is getting undef is known to either KeyAttr or forcearray (or both). I am trying to find it out from them :-)