Service/Dumper.php
protected function loadCurrentSitemapIndex($filename)
    {
        if (!file_exists($filename)) {
            return array();
        }

        $urlsets = array();
        $index = simplexml_load_file($filename);
        foreach ($index->children() as $child) {
            /** @var $child \SimpleXMLElement */
            if ($child->getName() == 'sitemap') {
                if (!isset($child->loc)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'loc' attribute"
                    );
                }
                $basename = preg_replace(
                    '/^' . preg_quote($this->sitemapFilePrefix) . '\.(.+)\.xml(?:\.gz)?$/',
                    '\1',
                    basename($child->loc)
                ); // cut .xml|.xml.gz

                if (!isset($child->lastmod)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'lastmod' attribute"
                    );
                }
                $lastmod = new \DateTime($child->lastmod);
                $urlsets[$basename] = $this->newUrlset($basename, $lastmod);
            }
        }

        return $urlsets;
    }
protected function loadCurrentSitemapIndex($filename)
    {
        if (!file_exists($filename)) {
            return array();
        }

        $urlsets = array();
        $index = simplexml_load_file($filename);
        foreach ($index->children() as $child) {
            /** @var $child \SimpleXMLElement */
            if ($child->getName() == 'sitemap') {
                if (!isset($child->loc)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'loc' attribute"
                    );
                }
                $basename = preg_replace(
                    '/^' . preg_quote($this->sitemapFilePrefix) . '\.(.+)\.xml(?:\.gz)?$/',
                    '\1',
                    basename($child->loc)
                ); // cut .xml|.xml.gz

                if (!isset($child->lastmod)) {
                    throw new \InvalidArgumentException(
                        "One of referenced sitemaps in $filename doesn't contain 'lastmod' attribute"
                    );
                }
                $lastmod = new \DateTime($child->lastmod);
                $urlsets[$basename] = $this->newUrlset($basename, $lastmod);
            }
        }

        return $urlsets;
    }
protected function loadCurrentSitemapIndex ( $ filename ) { if ( ! file_exists ( $ filename ) ) { return array ( ) ; } $ urlsets = array ( ) ; $ index = simplexml_load_file ( $ filename ) ; foreach ( $ index -> children ( ) as $ child ) { /** @var $child \SimpleXMLElement */ if ( $ child -> getName ( ) == 'sitemap' ) { if ( ! isset ( $ child -> loc ) ) { throw new \ InvalidArgumentException ( "One of referenced sitemaps in $filename doesn't contain 'loc' attribute" ) ; } $ basename = preg_replace ( '/^' . preg_quote ( $ this -> sitemapFilePrefix ) . '\.(.+)\.xml(?:\.gz)?$/' , '\1' , basename ( $ child -> loc ) ) ; // cut .xml|.xml.gz if ( ! isset ( $ child -> lastmod ) ) { throw new \ InvalidArgumentException ( "One of referenced sitemaps in $filename doesn't contain 'lastmod' attribute" ) ; } $ lastmod = new \ DateTime ( $ child -> lastmod ) ; $ urlsets [ $ basename ] = $ this -> newUrlset ( $ basename , $ lastmod ) ; } } return $ urlsets ; }
Loads sitemap index XML file and returns array of Urlset objects

@param string $filename

@return Urlset[]
@throws \InvalidArgumentException
Loads sitemap index XML file and returns array of Urlset objects