protected function MigrateItemsXML::getIDsFromXML in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/xml.inc \MigrateItemsXML::getIDsFromXML()
Given an XML object, parse out the IDs for processing and return them as an array. The location of the IDs in the XML are based on the item xpath and item ID xpath set in the constructor. eg, xpath = itemXpath . '/' . itemIDXpath IDs are cached. The list of IDs are returned from the cache except when this is the first call (ie, cache is NULL) OR the refresh parameter is TRUE.
Parameters
SimpleXMLElement $xml: SimpleXMLElement
Return value
array
File
- plugins/
sources/ xml.inc, line 663 - Support for migration from XML sources.
Class
- MigrateItemsXML
- Implementation of MigrateItems, for providing a list of IDs and for retrieving a parsed XML document given an ID from this list.
Code
protected function getIDsFromXML(SimpleXMLElement $xml) {
$result = $xml
->xpath($this->itemXpath);
$ids = array();
if ($result) {
foreach ($result as $element) {
if (!isset($element)) {
continue;
}
// Namespaces must be reapplied after xpath().
$this
->registerNamespaces($element);
$id = $this
->getItemID($element);
if (!is_null($id)) {
$ids[] = (string) $id;
}
}
}
return array_unique($ids);
}