44
1
using System;
2
using System.Net;
3
using System.Xml;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
string sitemapURL = "https://seoagilitytools.com/sitemap.xml";
10
/*Create a new instance of the System.Net Webclient*/
11
WebClient wc = new WebClient();
12
/*Set the Encodeing on the Web Client*/
13
wc.Encoding = System.Text.Encoding.UTF8;
14
/* Download the document as a string*/
15
string sitemapString = wc.DownloadString(sitemapURL);
16
/*Create a new xml document*/
17
XmlDocument urldoc = new XmlDocument();
18
/*Load the downloaded string as XML*/
19
urldoc.LoadXml(sitemapString);
20
/*Create an list of XML nodes from the url nodes in the sitemap*/
21
XmlNodeList xmlSitemapList = urldoc.GetElementsByTagName("url");
22
/*Loops through the node list and prints the values of each node*/
23
foreach (XmlNode node in xmlSitemapList)
24
{
Cached Result