Here I am sharing a simple PHP script to generate number of txt file from Sitemap.xml. This is a simple PHP script I wrote quickly for myself to create number of .txt files according to length of sitemap.xml for my page.
This script will help you If you want to generate random .txt file from the URL existed in sitemap.xml.
Follow the steps to generate random URL .txt file :
Follow the steps to generate random URL .txt file :
Step #1 : Generate & Download sitemap.xml for your website.
There are number of websites where you can generate sitemap.xml like :
you can also generate sitemap.xml by visiting link http://www.yourwebsite.com/sitemap.xml
Step #2 : Run the below script to generate random URL .txt file :
<?php function xmldata($xmlurl){ $i=1; $ucount=1; $rss=simplexml_load_file($xmlurl); $rss_split=array(); foreach ($rss->channel->url as $item){ echo $link = (string) $item->loc; // Url Link $file = 'folderName/adurl/'.$i.'.txt'; //folder path to generate url.txt $fh = fopen($file, 'w') or die("can't open file"); $url =$link; fwrite($fh, $url);fclose($fh); $i++; } return true; } $xmlurl='http://localhost/shared/ad-ref/yourfoldername/29-oct/sitemap.xml'; //sitemap.xml system path xmldata($xmlurl);?>
Step #3 : Run this file on local server.
if you run this file on local server it will generate random URL .txt file in adurl folder.
Each .txt file contains URL of your website.
Note: Only a member of this blog may post a comment.