c# : Read XML from URL

There are multiple methods to capture XML from a URL, but this particular example is helpful when you are dealing with special characters of foreign languages. The loaded XML will display them in correct format for the charset specified.

//Include the following packages
using System.Net;
using System.IO;

//request the particular web page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://feeds.feedburner.com/pointsharepoint?format=xml");

//define the login credentials of the requested file/page
request.Credentials = new NetworkCredential(”UserName”, “Password”);

//get the response from the request
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

//create a stream to hold the contents of the response
Stream receiveStream = response.GetResponseStream();

//create your XML document
XmlDocument mySourceDoc = new XmlDocument();

//load the file from the stream
mySourceDoc.Load(receiveStream);

//close the stream
receiveStream.Close()