You are here

protected function SimpleXml::openSourceUrl in Migrate Plus 8.2

Same name and namespace in other branches
  1. 8.5 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()
  2. 8.3 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()
  3. 8.4 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::openSourceUrl()

Opens the specified URL.

Parameters

$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_parser

Code

protected function openSourceUrl($url) {
  $xml_data = $this
    ->getDataFetcherPlugin()
    ->getResponseContent($url);
  $xml = simplexml_load_string($xml_data);
  $this
    ->registerNamespaces($xml);
  $xpath = $this->configuration['item_selector'];
  $this->matches = $xml
    ->xpath($xpath);
  foreach (libxml_get_errors() as $error) {
    $error_string = self::parseLibXmlError($error);
    throw new MigrateException($error_string);
  }
  return TRUE;
}