function tripal_pub_remote_search_AGL_get_subfield

2.x tripal_pub.AGL.inc tripal_pub_remote_search_AGL_get_subfield($xml)
3.x tripal_chado.pub_importer_AGL.inc tripal_pub_remote_search_AGL_get_subfield($xml)
1.x AGL.inc tripal_pub_remote_search_AGL_get_subfield($xml)

Used for parsing of the XML results to get a set of subfields

Parameters

$xml: The XMl object to read

Return value

An array of codes and their values

Related topics

2 calls to tripal_pub_remote_search_AGL_get_subfield()
tripal_pub_AGL_parse_pubxml in tripal_pub/includes/importers/tripal_pub.AGL.inc
Parse publication XML for a single publication
tripal_pub_remote_search_AGL_get_author in tripal_pub/includes/importers/tripal_pub.AGL.inc
Used for parsing of the XML results to get details about an author

File

tripal_pub/includes/importers/tripal_pub.AGL.inc, line 961
Importer for the USDA Agricultural Library (Agricola).

Code

function tripal_pub_remote_search_AGL_get_subfield($xml) {
  $codes = array();
  while ($xml->read()) {
    $sub_element = $xml->name;
    // when we've reached the end of the datafield element then break out of the while loop
    if ($xml->nodeType == XMLReader::END_ELEMENT and $sub_element == 'datafield') {
      return $codes;
    }
    // if inside the subfield element then get the code
    if ($xml->nodeType == XMLReader::ELEMENT and $sub_element == 'subfield') {
      $code = $xml->getAttribute('code');
      $xml->read();
      $value = $xml->value;
      $codes[$code] = $value;
    }
  }
  return $codes;
}