Hi Monks, I have an XML file as shown below. As you can see, it contains 2 different types of tables - Phones and Subs. I have trouble reading/printing them out. I keep getting the error "Out of memory!". Just a note, when I manually remove the "<anon>" tags, I can use the same code to read/print the data. Thanks.
my $xml = new XML::Simple; my $data = $xml->XMLin("testing.xml"); my $e; foreach $e (@{$data->{Phones}}) { print "\n$e->{Manufacturer}"; print "\n$e->{Model}"; print "\n$e->{Version}"; print "\n$e->{Count}"; print "\n==========================="; }
<?xml version='1.0'?> <terminalversioncount> <anon> <Phones> <Count>2</Count> <Manufacturer>Company X</Manufacturer> <Model>P90</Model> <Version>RM-194</Version> </Phones> </anon> <anon> <Phones> <Count>7</Count> <Manufacturer>Rocket Inc</Manufacturer> <Model>PlugX</Model> <Version>1.01</Version> </Phones> </anon> <anon> <Subs> <MNO_ID>7222</MNO_ID> <NAME></NAME> <PNAME></PNAME> <PURCHASE_CODE>7224</PURCHASE_CODE> </Subs> </anon> <anon> <Subs> <MNO_ID>7223</MNO_ID> <NAME></NAME> <PNAME></PNAME> <PURCHASE_CODE>7224</PURCHASE_CODE> </Subs> </anon> </terminalversioncount>

In reply to XML::Simple - storing/retrieving 2 tables into 1 XML file by iphony

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.