I am using Bio::DB::EUtilities to query the Pubmed DB with given PMIDs (Pubmed Id).
use Bio::DB::EUtilities;
use strict;
use warnings;
my @ids = (23298400);
my $factory = Bio::DB::EUtilities->new(-eutil => 'efetch',
-email => 'mymail@foo.bar',
-db => 'pubmed',
-retmode => 'xml',
-id => \@ids);
$factory -> get_Response(-file => 'pubmed_response.xml');
Is there a way to directly access the objects (e.g. abstract) instead of writing the response to file and using XML::Twig or so?
2 answers
You can just store the content of the response instead of writing it to a file. That would be:
my $xml = $factory->get_Response->content;
Now, $xml can be parsed to get whatever information you want. For example, you could look for the 'Abstract' node in the XML:
This prints the abstract, though you could store it or do something else with it. You could also try getting different return types, as Sudeep mentioned.
EDIT: For reference, I also answered this question on Stack Overflow with more detail.
This table tells that if you use rettype=abstract & retrymode=text you should probably get abstract as text. I've checked it using efetch but not using bioperl, see it here: http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=11748933,11700088&rettype=abstract&retmode=text
Log in to answer this question.