0 and strlen($_REQUEST['AddWorldCatSearch-SearchString']) > 0) { $searchURL = 'http://www.worldcat.org/webservices/catalog/content/libraries/$_REQUEST['OCLCNumber']?location=. $_REQUEST['Location']'; $searchURL .= '&startLibrary='. $_REQUEST[StartLibrary]; $searchURL .= '&maximumLibraries='. $_REQUEST[MaximumLibraries]; $searchURL .= 'libtype='. $_REQUEST[LibType]; $searchURL .= '&wskey='. $WorldCatAPIKey; $xml = simplexml_load_file($searchURL); //Converts the well-formed XML document in the given file to an object // Calculate the library counts $xml->registerXPathNamespace("marc", "http://www.loc.gov/MARC21/slim"); // Registers a namespace context for the next XPath query // Go get the Library Locations in the search results $xml->registerXPathNamespace("marc", "http://www.loc.gov/MARC21/slim"); $location_ids = ""; $locations = $xml->xpath("//marc:record/marc:datafield[@tag='020']/marc:subfield[@code='a']"); // TODO : Set correct Marc Datafield for location foreach ((array)$locations as $location) { if (strlen($location) > 1) { if (strpos($location[0], " ") > 0) { $location_ids = $location_ids . substr($location, 0, strpos($location, " ")); } else { $location_ids = $location_ids = $location_ids . $location[0]; } if ($location != end($locations)) { $location_ids = $location_ids . ','; } } } foreach($xml->xpath('//marc:record') as $publication ) { $publication['xmlns:marc'] = 'http://www.loc.gov/MARC21/slim'; $field = simplexml_load_string($publication->asXML()); $barcode = $field->xpath("marc:datafield[@tag='020']/marc:subfield[@code='a']"); // TODO : Set correct Marc Datafield for barcode $location = $field->xpath("marc:datafield[@tag='260']/marc:subfield[@code='b']"); // // TODO : Set correct Marc Datafield for location $sumloc = array_sum($location); // Calculate the sum of values in the location array $publication_date = $field->xpath("marc:datafield[@tag='260']/marc:subfield[@code='c']"); $publication_year=date("Y", strtotime("$publication_date")); // Extracting the full numeric representation of the publication year (4 digits) from publication_date if (strpos($location[0], " ") > 0) { $location_1 = substr($location[0], 0, strpos($location[0], " ")); } else { $location_1 = $location[0]; } $oclcnumber = $field->xpath("marc:controlfield[@tag='001']"); } ?>