function tripal_pub_PMID_parse_abstract

2.x tripal_pub.PMID.inc tripal_pub_PMID_parse_abstract($xml, &$pub)
3.x tripal_chado.pub_importer_PMID.inc tripal_pub_PMID_parse_abstract($xml, &$pub)
1.x PMID.inc tripal_pub_PMID_parse_abstract($xml, &$pub)

Parses the section from the XML returned from PubMed that contains information about the abstract

Parameters

$xml: The XML to parse

$pub: The publication object to which additional details will be added

Related topics

1 call to tripal_pub_PMID_parse_abstract()
tripal_pub_PMID_parse_article in tripal_pub/includes/importers/tripal_pub.PMID.inc
Parses the section from the XML returned from PubMed that contains information about an article.

File

tripal_pub/includes/importers/tripal_pub.PMID.inc, line 661
This file provides support for importing and parsing of results from the NCBI PubMed database. The functions here are used by both the publication importer setup form and the publication importer.

Code

function tripal_pub_PMID_parse_abstract($xml, &$pub) {
  $abstract = '';

  while ($xml->read()) {
    $element = $xml->name;

    if ($xml->nodeType == XMLReader::END_ELEMENT and $element == 'Abstract') {
      // we've reached the </Abstract> element so return
      $pub['Abstract'] = $abstract;
      return;
    }
    // the abstract text can be just a singe paragraph or be broken into multiple
    // abstract texts for structured abstracts.  Here we will just combine then
    // into a single element in the order that they arrive in HTML format
    if ($xml->nodeType == XMLReader::ELEMENT) {
      switch ($element) {
        case 'AbstractText':
          $label = $xml->getAttribute('Label');
          $xml->read();
          if ($label) {
            $part = "<p><b>$label</b></br>" . $xml->value . '</p>';
            $abstract .= $part;
            $pub['Structured Abstract Part'][] = $part;
          }
          else {
            $abstract .= "<p>" . $xml->value . "</p>";
          }
          break;
        case 'CopyrightInformation':
          $xml->read();
          $pub['Copyright'] = $xml->value;
          break;
        default:
          break;
      }
    }
  }
}