advait has asked for the wisdom of the Perl Monks concerning the following question:
Can anyone please suggest how can I retrieve accnum in experiment. Using XML twig I could retrieve secondaryaccession.experiments total-hybs="629" total-samples="733" total="21" to="21" fr +om="1"> − <experiment accnum="E-GEOD-8918" array="Agilent Human Genome CGH M +icroarray 44B [G4410B]" biosamples-png="download/mageml/E-GEOD-8918.b +iosamples.png" biosamples-svg="download/mageml/E-GEOD-8918.biosamples +.svg" fgem="download/mageml/E-GEOD-8918.processed.zip" fgem-count="87 +" hybs="87" id="1636341195" name="CGH profiling of 87 indolent non-ho +dgkin s lymphoma (NHL)" releasedate="2008-06-19" samples="174" sdrf +="download/mageml/E-GEOD-8918.sdrf.txt" species="Homo sapiens" two-co +lumns="download/mageml/E-GEOD-8918.2columns.txt"> − <users> <user id="1"/> </users> − <secondaryaccessions> <secondaryaccession>GSE8918</secondaryaccession> </secondaryaccessions> − </experiment>
Thank youuse strict; use XML::Twig; my $t= new XML::Twig( TwigHandlers=> { experiment => \&experiment}); $t->parsefile( '/home/adi/lwp_cgh_hs.xml'); exit; sub experiment { my ($t, $experiment)= @_; my %experiment; $experiment{secondaryaccessions}= $experiment->field( 'secondaryac +cessions'); # $experiment{name}= $experiment->field( 'experimentName'); #$experiment{description}= $experiment->field( 'Description'); $experiment{secondaryaccession}= join ':', map {$_->text || ''} @{[$experiment->children( 'secondaryaccession' +)]}; print "$experiment\n"; print "$experiment{secondaryaccessions}: \n"; print " : $experiment{secondaryaccession}\n"; $experiment->delete; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML parsing
by toolic (Bishop) on Jul 07, 2008 at 16:29 UTC | |
|
Re: XML parsing
by Your Mother (Archbishop) on Jul 08, 2008 at 00:21 UTC | |
|
Re: XML parsing
by Anonymous Monk on Jul 07, 2008 at 16:29 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |