VIPnytt / SitemapParser

XML Sitemap parser class compliant with the Sitemaps.org protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to parse sitemap from file?

KarelWintersky opened this issue · comments

Is it possible to parse sitemap from local file?

Yes, that's possible.

Just add the contents of the file as the second parameter of parse(). The URL is still required to determine filetype, but won't be crawled.

Example:

$parser = new SitemapParser();
$parser->parse('https://example.com/sitemap.xml', 'INSERT_FILE_CONTENTS_HERE');
foreach ($parser->getURLs() as $url => $tags) {
    echo $url . '<br>';
}