PHP code example of kalwa / kalwa-parser

1. Go to this page and download the library: Download kalwa/kalwa-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kalwa / kalwa-parser example snippets



use Kalwa\KalwaParser;
use Kalwa\KalwaParser\Exceptions\SitemapParserException;

 try {
            $parser = new KalwaParser('MyCustomUserAgent');
            $parser->parse('https://themeselection.com/sitemap_index.xml');

            foreach ($parser->getSitemaps() as $url => $tags) {
             
                echo 'URL: ' . $url . '<br>';
             
                echo '<hr>';
            }
            foreach ($parser->getURLs() as $url => $tags) {
                echo $url . '<br>';  
            }
        } catch (SitemapParserException $e) {
            echo $e->getMessage();
        }