Skip to content

Commit

Permalink
Fixing an issue with Pubmed entries without abstracts
Browse files Browse the repository at this point in the history
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
konrad committed Apr 1, 2012
1 parent 4f37b15 commit 0168464
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PubmedParserFetcher.body.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.:
Expand Down

1 comment on commit 0168464

@konrad
Copy link
Owner Author

@konrad konrad commented on 0168464 Apr 1, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.