Horje

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



Single Articles
How to extract URLs from xml sitemap on PHPPHP URL/LINK Tutorial


Related Articles
How to add PHP File Get Content PHP URL/LINK Tutorial
How to add PHP cURL CURLOPT PHP URL/LINK Tutorial
How to load XML Sitemap URLs PHP URL/LINK Tutorial
How to get file size from a remote url in PHP PHP URL/LINK Tutorial

Type:
Php
Category:
Web Tutorial
Sub Category:
PHP URL/LINK Tutorial
Uploaded by:
Admin



Share on: