Created
June 14, 2018 18:44
-
-
Save bradmarshall/cad7f4d5551664f005f411e168fddfb1 to your computer and use it in GitHub Desktop.
Read all URL's from XML sitemap file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Requires PHP DOM extension. Works with both local files and live ones on the web! | |
if(!isset($argv[1])) { | |
print("getSiteMapURLs.php error: This script takes one argument (the path of the site map to parse).".PHP_EOL); | |
die(); | |
} | |
$urls = ""; | |
$DomDocument = new DOMDocument(); | |
$DomDocument->preserveWhiteSpace = false; | |
$DomDocument->load($argv[1]); | |
$DomNodeList = $DomDocument->getElementsByTagName('loc'); | |
foreach($DomNodeList as $url) { | |
print($url->nodeValue.PHP_EOL); | |
} | |
//display 'em all | |
print($urls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment