You are here

function _biblio_pm_create_node_from_xml in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 modules/pubmed/biblio_pm.module \_biblio_pm_create_node_from_xml()
  2. 7 modules/pubmed/biblio_pm.module \_biblio_pm_create_node_from_xml()
  3. 7.2 modules/pubmed/biblio_pm.module \_biblio_pm_create_node_from_xml()
2 calls to _biblio_pm_create_node_from_xml()
biblio_pm_biblio_xml_import in pubmed/biblio_pm.module
_biblio_pm_import_pmids in pubmed/biblio_pm.module

File

pubmed/biblio_pm.module, line 112

Code

function _biblio_pm_create_node_from_xml($xml, $terms, $batch, $session_id) {
  module_load_include('php', 'biblio_pm', 'EntrezPubmedArticle');
  $nids = array();
  $dups = array();
  $node = new stdClass();
  $data = new BiblioEntrezPubmedArticle();
  foreach ($xml
    ->xpath('//PubmedArticle') as $article) {

    //$data->setArticle($article);
    $node = $data
      ->setArticle($article)
      ->getBiblio();
    if (isset($node)) {
      if (!empty($terms)) {
        if (!isset($node['taxonomy'])) {
          $node['taxonomy'] = array();
        }
        $node['taxonomy'] = array_merge($terms, $node['taxonomy']);
      }
      if (!($dup = biblio_pm_check_md5($node['biblio_pubmed_md5']))) {
        $nid = biblio_save_node($node, $batch, $session_id);
        if (isset($nid)) {
          $nids[] = $nid;
        }
      }
      else {
        $dups[] = $dup;
      }
      $node = null;
    }
    $start++;
  }
  return array(
    $nids,
    $dups,
  );
}