Get nodes from xml files

agigefrof

New Member
How to parse the xml file? \[code\]<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <sitemap> <loc>link</loc> <lastmod>2011-08-17T08:23:17+00:00</lastmod> </sitemap> <sitemap> <loc>link</loc> <lastmod>2011-08-18T08:23:17+00:00</lastmod> </sitemap> </sitemapindex>\[/code\]I am new to XML, I tried this, but it seems to be not working :\[code\] XmlDocument xml = new XmlDocument(); //* create an xml document object. xml.Load("sitemap.xml"); XmlNodeList xnList = xml.SelectNodes("/sitemapindex/sitemap"); foreach (XmlNode xn in xnList) { String loc= xn["loc"].InnerText; String lastmod= xn["lastmod"].InnerText; }\[/code\]
 
Back
Top