I\'m trying to retrieve an XML document from a server and store it locally as a string. In desktop .Net I didn\'t need to, I just did:
string xmlFile
I rather think you've overcomplicated things. Below is a very simple example which requests an XML document from a URI over HTTPS.
It downloads the XML asynchronously as a string and then uses XDocument.Parse()
to load it.
private void button2_Click(object sender, RoutedEventArgs e)
{
WebClient wc = new WebClient();
wc.DownloadStringCompleted += HttpsCompleted;
wc.DownloadStringAsync(new Uri("https://domain/path/file.xml"));
}
private void HttpsCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
this.textBox1.Text = xdoc.FirstNode.ToString();
}
}