Thank you, that works. However, now I am still having issues with my original XML above. Using:
my $doc = $xs1->XMLin($file, forcearray => 1, keyattr => {client_syste +m => 'Customer Care'});
then Data::Dumper gives me output like this:
$VAR1 = { 'client_system' => [ { 'business_area' => [ { 'component' => [ { 'component_lib' => [ { 'class_set' => [ { 'data_type' => '1', 'linked_characteristic_name' => '4-MTH-AV +G-UTIL', 'version' => '2.0', 'name' => 'Active Strategy 2', 'is_protected' => 'false', 'base_class_set' => [ { 'interval' => [ { 'outcome' => [ { 'uniqueID' => '2', 'displayPosition' => '1', 'name' => 'low-199' } ], 'is_Others' => ['false'], 'range' => ['low-199'], 'name' => 'low-199' + + + }, + + { + + 'outcome' => [ + + + { + + 'uniqueID' => '3', + + + 'displayPosition' => '2', + + + 'name' => '200-499' } ], 'is_Others' => ['false'], 'range' => ['200-499'], 'name' => '200-499' }, { 'outcome' => [ { 'uniqueID' => '4', 'displayPosition' => '3' +, 'name' => '500-899' } ], 'is_Others' => ['false'], 'range' => ['500-899'], 'name' => '500-899' }, { 'outcome' => [ { 'uniqueID' => '1', 'displayPosition' => +'2147483647', 'name' => 'Others' } ], 'is_Others' => ['true'], 'name' => 'Others' } ] } ], 'obj_info' => [ { 'obj_revision' => '1', 'version' => '2.0', 'name' => 'CS A1524 CD GM Active Strategy +2', 'library_unique_id' => '00000071', } ] } ], 'type' => 'class_set' } ] } ], 'name' => 'GM Business Area', 'analytics' => [ {} ] } ], . . .
Sorry for the mess but I'm tired of formatting. Anyway, I basically want to get all of the interval=>names for the business_area client_system and I have:
my $doc = $xs1->XMLin($file, forcearray => 1, keyattr => {client_syste +m => 'Customer Care'}); foreach my $key (keys (%{$doc->{client_system}})){ if($key eq 'business_area') { print $doc->{client_system}[$key]->{component}[0]->{component_ +lib}[0]->{class_set}[0]->{base_class_set[0]->{interval}{'range'}, "\n +"; } }
or something like that. Just confused with the syntax on the print command. Probably also have to loop through again to get all the interval names. Thanks in advance

In reply to Re^4: XML::Simple Multi-Layered by eide
in thread XML::Simple Multi-Layered by eide

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.