Permalink
Browse files

Fixing an issue with Pubmed entries without abstracts

Any Pubmed entries that is lacking an abstract text causes an error
during the parsing of the XML file. As example use this article:

http://www.ncbi.nlm.nih.gov/pubmed/22442467

You can download its XML file with

$ curl "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=$22442467&retmode=xml" > 22442467.xml

The is no "Abstract" and "AbstractText" element in there. The
modification circumvent the error and an empty string is returned by
the modified function.
  • Loading branch information...
1 parent 4f37b15 commit 0168464ad87790e8afb57889f7a4bda2da4163d2 @konrad committed Apr 1, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 PubmedParserFetcher.body.php
@@ -295,6 +295,10 @@ function doi()
* as it is a PHP keyword.
*/
function abstr() {
+ // Some Pubmed entries are missing an abtract
+ if (is_array($this->medline->PubmedArticle->MedlineCitation->Article->Abstract->AbstractText) == FALSE){
+ return "";
+ }
foreach ( $this->medline->PubmedArticle->MedlineCitation->Article->Abstract->AbstractText as $p ) {
// Abstract paragraphs may be preceded by a label.
// The label is given as an XML parameter, e.g.:

1 comment on commit 0168464

Owner

konrad commented on 0168464 Apr 1, 2012

PS: I am not a PHP programmer so there might be more idiomatic solutions for this problem.

Please sign in to comment.