Hi all. I have this xml file :- http://www.genome.jp/kegg-bin/download?entry=pon01100&format=kgml

I even tried parsing it with XML:Simple as :-

use strict; use XML::Simple; use Data::Dumper; my $xml_hash = XMLin('pon01100.xml'); print Dumper($xml_hash);

Its dumping the output as desired to the console.

$VAR1 = { 'reaction' => { 'rn:R07892' => { 'substrate' => { 'name' => 'cpd:C +16331', 'id' => '3038' }, 'type' => 'reversible', 'id' => '983', 'product' => { 'name' => 'cpd:C16 +332', 'id' => '2201' } }, 'rn:R02687' => { 'substrate' => { 'name' => 'cpd:C +00641', 'id' => '3607' }, 'type' => 'reversible', 'id' => '3606', 'product' => { 'name' => 'cpd:C01 +885', 'id' => '3608' } }, 'rn:R05640' => { 'substrate' => { 'name' => 'cpd:C +01724', 'id' => '2269' }, 'type' => 'reversible', 'id' => '651', 'product' => { 'name' => 'cpd:C11 +455', 'id' => '2270' } }......and so on......
What I want to do is for each of reactions (named rn:....) I want the substrate "id" and its corresponding all product "id". There could be cases when there would be two or more products for a substrate. For each of the reactions ,I want to save "substrate id" and all its corresponding "product id". Please help

In reply to Parsing an XML file by zing

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.