protected function SimpleXml::fetchNextRow in Migrate Plus 8.5
Same name and namespace in other branches
- 8.2 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::fetchNextRow()
- 8.3 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::fetchNextRow()
- 8.4 src/Plugin/migrate_plus/data_parser/SimpleXml.php \Drupal\migrate_plus\Plugin\migrate_plus\data_parser\SimpleXml::fetchNextRow()
Retrieves the next row of data. populating currentItem.
Retrieves from the open source URL.
Overrides DataParserPluginBase::fetchNextRow
File
- src/
Plugin/ migrate_plus/ data_parser/ SimpleXml.php, line 62
Class
- SimpleXml
- Obtain XML data for migration using the SimpleXML API.
Namespace
Drupal\migrate_plus\Plugin\migrate_plus\data_parserCode
protected function fetchNextRow() {
$target_element = array_shift($this->matches);
// If we've found the desired element, populate the currentItem and
// currentId with its data.
if ($target_element !== FALSE && !is_null($target_element)) {
foreach ($this
->fieldSelectors() as $field_name => $xpath) {
foreach ($target_element
->xpath($xpath) as $value) {
if ($value
->children() && !trim((string) $value)) {
$this->currentItem[$field_name] = $value;
}
else {
$this->currentItem[$field_name][] = (string) $value;
}
}
}
// Reduce single-value results to scalars.
foreach ($this->currentItem as $field_name => $values) {
if (is_array($values) && count($values) == 1) {
$this->currentItem[$field_name] = reset($values);
}
}
}
}