This code worked for me (using OO interface):
#!/usr/bin/perl use strict; use XML::Simple; use Data::Dumper; my $xml_obj = XML::Simple->new(ForceArray => ['tables']); # xml my $xml = $xml_obj->XMLin('test.xml'); print Dumper($xml); exit;
Also, double check for any errors in your xml file.

Output:
$VAR1 = { 'detail' => { 'rate' => { 'name' => 'RATE', 'type' => 'number', 'size' => '', 'mnemonic' => 'rate' }, 'date' => { 'name' => 'The_Date', 'type' => 'date', 'size' => '8', 'mnemonic' => 'date' }, 'name' => 'schema.detail', 'requiredfields' => 'date,rate,scenarioname' }, 'junk1' => { 'name' => 'rates', 'requiredfields' => 'date,rate', 'type' => 'junk1' }, 'junk2' => { 'name' => 'demands', 'requiredfields' => '', 'type' => 'junk2' }, 'xyz' => { 'cpr' => { 'required' => 'true', 'calc' => 'CASE WHEN SUM(a) != 0 THEN roun +d((1-power(1-sum(b/100*a)/sum(a),12))*100,2) ELSE SUM(0) END', 'name' => 'CPR', 'cohort' => 'false', 'type' => 'summed', 'size' => '8', 'mnemonic' => 'cpr' }, 'obsdate' => { 'required' => 'false', 'calc' => 'to_char(asofdate,\'mm/dd/yy +yy\')', 'name' => 'asofdate', 'cohort' => 'true', 'type' => 'summed', 'size' => '8', 'mnemonic' => 'obsdate' }, 'model' => { 'required' => 'true', 'calc' => 'trim(\'model\')', 'name' => 'model', 'cohort' => 'true', 'type' => 'summed', 'size' => '', 'mnemonic' => 'model' }, 'name' => 'schema.xyz', 'requiredfields' => 'obsdate,wac,wala,wam', 'loancount' => { 'required' => 'false', 'calc' => 'sum(LOANCOUNT)', 'name' => 'LoanCount', 'cohort' => 'fale', 'type' => 'summed', 'size' => '8', 'mnemonic' => 'loancount' }, 'new' => { 'required' => 'false', 'name' => 'ISNEW', 'cohort' => 'true', 'type' => 'char', 'size' => '', 'mnemonic' => 'new' } } };

Code w/ loop:
#!/usr/bin/perl use strict; use XML::Simple; use Data::Dumper; my $xml_obj = XML::Simple->new(ForceArray => ['tables']); # xml my $xml = $xml_obj->XMLin('test.xml'); for my $table (keys %$xml) { print Dumper($table); } exit;

In reply to Re: using xml::simple with unknown xml structure by shiza
in thread using xml::simple with unknown xml structure by ctaustin

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.