public function MigrateListXML::computeCount in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/xml.inc \MigrateListXML::computeCount()
Return a count of all available IDs from the source listing. The default implementation assumes the count of top-level elements reflects the number of IDs available - in many cases, you will need to override this to reflect your particular XML structure.
Overrides MigrateList::computeCount
File
- plugins/
sources/ xml.inc, line 129 - Support for migration from XML sources.
Class
- MigrateListXML
- Implementation of MigrateList, for retrieving a list of IDs to be migrated from an XML document.
Code
public function computeCount() {
$xml = simplexml_load_file($this->listUrl);
$this
->registerNamespaces($xml);
// Number of sourceid elements beneath the top-level element.
$count = count($xml);
// Additionally, if there are any namespaces registered, try to count
// elements with namespaces as well.
if ($namespaces = $xml
->getNamespaces()) {
foreach ($namespaces as $prefix => $url) {
$count += count($xml
->children($url));
}
}
return $count;
}