public function BiblioCrossRefClient::fetch in Bibliography Module 6.2
Same name and namespace in other branches
- 7 modules/crossref/biblio.crossref.client.php \BiblioCrossRefClient::fetch()
- 7.2 modules/crossref/biblio.crossref.client.php \BiblioCrossRefClient::fetch()
File
- modules/
crossref/ biblio.crossref.client.php, line 54
Class
Code
public function fetch() {
$this->query = $this->url . '?pid=' . $this->pid . '&noredirect=true&format=unixref&id=doi%3A' . $this->doi;
if (!($xml = file_get_contents($this->query))) {
drupal_set_message(t('Could not open crossref.org for XML input'), 'error');
return;
}
$this->nodes = array();
$this->parser = drupal_xml_parser_create($xml);
// use case-folding so we are sure to find the tag in
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, FALSE);
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, TRUE);
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'unixref_startElement', 'unixref_endElement');
xml_set_character_data_handler($this->parser, 'unixref_characterData');
if (!xml_parse($this->parser, $xml)) {
drupal_set_message(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->parser)), xml_get_current_line_number($this->parser)), 'error');
}
xml_parser_free($this->parser);
return $this->node;
}