Can anyone please suggest how can I retrieve accnum in experiment.
Here is one way to do it, after cleaning up what I think is the XML you want:
use strict; use warnings; use XML::Twig; my $xfile = <<EOF; <experiment accnum="E-GEOD-8918" array="Agilent Human Genome CGH Micro +array 44B [G4410B]" biosamples-png="download/mageml/E-GEOD-8918.biosa +mples.png" biosamples-svg="download/mageml/E-GEOD-8918.biosamples.svg +" fgem="download/mageml/E-GEOD-8918.processed.zip" fgem-count="87" hy +bs="87" id="1636341195" name="CGH profiling of 87 indolent non-hodgki +n s lymphoma (NHL)" releasedate="2008-06-19" samples="174" sdrf="do +wnload/mageml/E-GEOD-8918.sdrf.txt" species="Homo sapiens" two-column +s="download/mageml/E-GEOD-8918.2columns.txt"> <users> <user id="1"/> </users> <secondaryaccessions> <secondaryaccession>GSE8918</secondaryaccession> </secondaryaccessions> </experiment> EOF my $t= new XML::Twig(); $t->parse($xfile); my $experiment = $t->root(); print 'accnum = ', $experiment->att('accnum'), "\n";

prints:

accnum = E-GEOD-8918

In reply to Re: XML parsing by toolic
in thread XML parsing by advait

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.