protected function SimpleXml::openSourceUrl in Migrate Plus 8.4
Same name and namespace in other branches
- 8.5 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()
- 8.2 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()
- 8.3 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()
Opens the specified URL.
Parameters
string $url: URL to open.
Return value
bool TRUE if the URL was successfully opened, FALSE otherwise.
Overrides DataParserPluginBase::openSourceUrl
File
- src/
Plugin/ migrate_plus/ data_parser/ SimpleXml.php, line 40
Class
- SimpleXml
- Obtain XML data for migration using the SimpleXML API.
Namespace
Drupal\migrate_plus\Plugin\migrate_plus\data_parserCode
protected function openSourceUrl($url) {
// Clear XML error buffer. Other Drupal code that executed during the
// migration may have polluted the error buffer and could create false
// positives in our error check below. We are only concerned with errors
// that occur from attempting to load the XML string into an object here.
libxml_clear_errors();
$xml_data = $this
->getDataFetcherPlugin()
->getResponseContent($url);
$xml = simplexml_load_string(trim($xml_data));
foreach (libxml_get_errors() as $error) {
$error_string = self::parseLibXmlError($error);
throw new MigrateException($error_string);
}
$this
->registerNamespaces($xml);
$xpath = $this->configuration['item_selector'];
$this->matches = $xml
->xpath($xpath);
return TRUE;
}