<?php

namespace webignition\WebResource\Sitemap\UrlExtractor;

class SitemapsOrgXmlIndexUrlExtractor extends UrlExtractor {

    public function extract($content) {
        $urls = array();
        $queryPath = new \QueryPath();
        
        try {
            $queryPath->withXML($content, 'sitemap loc')->each(function ($index, \DOMElement $domElement) use (&$urls) {
                if ($domElement->nodeName == 'loc') {
                    $urls[] = \trim($domElement->nodeValue);
                }                
            });            
        } catch (QueryPath\ParseException $parseException) {
            // Invalid XML
        }
        
        return $urls;
    }
    
}
<?php

namespace webignition\WebResource\Sitemap\UrlExtractor;

class SitemapsOrgXmlIndexUrlExtractor extends UrlExtractor {

    public function extract($content) {
        $urls = array();
        
        $xmlParser = new \Hobnob\XmlStreamReader\Parser();        
        $xmlParser->registerCallback(
            '/sitemapindex/sitemap',
            function( \Hobnob\XmlStreamReader\Parser $parser, \SimpleXMLElement $node) use (&$urls) {
                $urls[] = (string)$node;
            }
        );
        $xmlParser->parse($content);       
        
        return $urls;
    }
    
}
Switch sitemap index extractor to use sax speediness
Switch sitemap index extractor to use sax speediness
