I am still at procedural style programming. And so, oop code samples confuse me.
I found this oop style. Any chance you can show me how to convert this to procedural style ?
Test the code. It woks fine!
https://bytenota.com/parsing-an-xml-sitemap-in-php/
// sitemap url or sitemap file
$sitemap = 'https://bytenota.com/sitemap.xml';
// get sitemap content
$content = file_get_contents($sitemap);
// parse the sitemap content to object
$xml = simplexml_load_string($content);
// retrieve properties from the sitemap object
foreach ($xml->url as $urlElement) {
// get properties
$url = $urlElement->loc;
$lastmod = $urlElement->lastmod;
$changefreq = $urlElement->changefreq;
$priority = $urlElement->priority;
// print out the properties
echo 'url: '. $url . '<br>';
echo 'lastmod: '. $lastmod . '<br>';
echo 'changefreq: '. $changefreq . '<br>';
echo 'priority: '. $priority . '<br>';
echo '<br>---<br>';
}