Horje
How to load XML Sitemap URLs | PHP URL Code
How to load XML Sitemap URLs

A way to load xml sitemap its url


How to extract URLs from xml sitemap on PHP

An Easy way to extract urls from xml sitemap
index.php
Example: PHP
<?php


$affectedRow = 0;


$url1 = 'https://wordpress.org/plugins/sitemap-2.xml';

$xml = simplexml_load_file("$url1") or die('Sorry');

foreach ($xml->children() as $row) {
    $link = $row->loc;

echo $link;
echo '</br>';
    if (! empty($result)) {
        $affectedRow ++;
    } else {
        $error_message = mysqli_error($conn) . "\n";
    }
}






if ($affectedRow > 0) {
    $message = $affectedRow . " URLs have been crawled. It will index in the next crawl date";

    
} else {
    $message = "No records inserted";
}

?>

<div class="affected-row"><?php  echo $message; ?></div>
<?php if (! empty($error_message)) { ?>
<div class="error-message"><?php echo nl2br($error_message); ?></div>


			
<?php } ?>

Output should be:

How to extract URLs from xml sitemap on PHP



Read Full::
PHP URL Code
Category:
PHP Tutorial Code
Sub Category:
PHP URL Code
Uploaded:
3 weeks ago
Uploaded by:
Admin
Views:
3
Tested on:
PHP 7

Related Articles
How to add PHP File Get Content PHP URL Code
How to add PHP cURL CURLOPT PHP URL Code
How to load XML Sitemap URLs PHP URL Code

Single Articles
How to extract URLs from xml sitemap on PHP

Share on: