I want to edit my sitemap automatically after calling some function.
the parameters are just "add/delete" URL and "URL param".
If the URL exist in any of the file - delete the element, else, add new element like that:
<sitemap>
<loc>new url</loc>
</sitemap>
That is what I did:
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
string path = System.IO.Path.Combine(basePath, sitemapName);
doc.Load(path);
//Here to add/delete by the code
doc.Save(path);
That is my sitemap:
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>aviel</loc>
</sitemap>
</sitemapindex>