function tripal_pub_PMID_parse_date
2.x tripal_pub.PMID.inc | tripal_pub_PMID_parse_date($xml, $element_name) |
3.x tripal_chado.pub_importer_PMID.inc | tripal_pub_PMID_parse_date($xml, $element_name) |
1.x PMID.inc | tripal_pub_PMID_parse_date($xml, $element_name) |
Parses the section from the XML returned from PubMed that contains information regarding to dates
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_date()
- tripal_pub_PMID_parse_journal_issue in tripal_pub/
includes/ importers/ tripal_pub.PMID.inc - Parses the section from the XML returned from PubMed that contains information about a journal issue
File
- tripal_pub/
includes/ importers/ tripal_pub.PMID.inc, line 859 - 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_date($xml, $element_name) {
$date = array();
while ($xml->read()) {
$element = $xml->name;
if ($xml->nodeType == XMLReader::END_ELEMENT and $element == $element_name) {
// if we're at the </$element_name> then we're done
return $date;
}
if ($xml->nodeType == XMLReader::ELEMENT) {
switch ($element) {
case 'Year':
$xml->read();
$date['year'] = $xml->value;
break;
case 'Month':
$xml->read();
$month =
$date['month'] = $xml->value;
break;
case 'Day':
$xml->read();
$date['day'] = $xml->value;
break;
case 'MedlineDate':
// the medline date is when the date cannot be broken into distinct month day year.
$xml->read();
$date['year'] = preg_replace('/^(\d{4}).*$/', '\1', $xml->value);
$date['medline'] = $xml->value;
break;
default:
break;
}
}
}
}