Its basic appearance is:
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">;
<url>
<loc>http://miweb.com/</loc>;
<lastmod>2013-03-18</lastmod>
<changefreq>daily</changefreq>
</url>
<url>
<lastmod>2013-03-18</lastmod>
<changefreq>weekly</changefreq>
</url>
</urlset>
You must create a program which will receive as parameters the name of a text file containing the URLs, the modification date and the frequency of changes:
sitemapCreator urls.txt 2011-11-18 weekly
The text file would contain the list of the names of the files to be indexed, each line in a different line:
http://www.exercisescsharp.blogspot.com
http://www.exercisescsharp.blogspot.com/FirstExercises.html
http://www.exercisescsharp.blogspot.com
http://www.exercisescsharp.blogspot.com/FirstExercises.html
using System; using System.IO; using System.Collections.Generic; class SitemapCreator2 { static void Main(string[] param) { if (param.Length != 3) { Console.WriteLine("Error number of params."); return; } string file = param[0]; string date = param[1]; string frecuency = param[2]; ListListUrls = GetUrls(file); CreateSiteMap(ListUrls, frecuency, date); } static void CreateSiteMap(List listHtml, string frecuency, string lastUpdated) { try { StreamWriter writer = new StreamWriter(File.Create("sitemap.xml")); writer.WriteLine(""); writer.WriteLine(" "); foreach (string html in listHtml) { writer.WriteLine(" "); writer.Close(); } catch { Console.WriteLine("Error writing sitemap."); } } static List"); writer.WriteLine(" "); } writer.WriteLine("" + html + " "); writer.WriteLine("" + lastUpdated + " "); writer.WriteLine("" + frecuency + " "); writer.WriteLine("GetUrls(string nameFile) { try { StreamReader reader = new StreamReader(File.OpenRead(nameFile)); string line = ""; List urls = new List (); do { line = reader.ReadLine(); if (line != null) { urls.Add(line); } } while( line != null); reader.Close(); return urls; } catch { Console.WriteLine("Error reading file."); return null; } } }