Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

XML Remove problem

$
0
0

Hi guys,

i have this XML file

<?xml version="1.0" encoding="utf-8"?><urlset><url><loc>http://www.mydomain.com/</loc><lastmod>2016-01-06T03:45:13+00:00</lastmod><changefreq>daily</changefreq><priority>1.00</priority></url></urlset>



 // Delete Record
        public void DeleteSitemap(string url)
        {
//passing "http://www.mydomain.com"
            XDocument sitemapData = new XDocument();
            sitemapData.Root.Elements("url").Where(i => (string)i.Element("loc").Value == url).Remove();

            sitemapData.Save(HttpContext.Current.Server.MapPath("~/Sitemap.xml"));
        }


///this code would delete if the Root
///<urlset> is as such;


However, if my XML is as such

<?xml version="1.0" encoding="utf-8"?><urlset  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>http://www.mydomain.com/</loc><lastmod>2016-01-06T03:45:13+00:00</lastmod><changefreq>daily</changefreq><priority>1.00</priority></url></urlset>

The code wouldn't work anymore...

can anyone help me out?  I've been searching for hours.

thank you


Please do not forget to click “Vote as Helpful” if the reply helps/directs you toward your solution and or "Mark as Answer" if it solves your question. This will help to contribute to the forum.


Viewing all articles
Browse latest Browse all 2535

Trending Articles