I am using the following methods to download an xml file
private void LoadXMLFile()
{
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(XMLFileLoaded);
xmlClient.DownloadStringAsync(new Uri("chart.xml", UriKind.RelativeOrAbsolute));
}
void XMLFileLoaded(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
string xmlData = e.Result;
HtmlPage.Window.Alert(xmlData);
x2 = new XDocument(xmlData);
}
}
I want to use the information inside xmlData to build an xDocument, like I am trying to do in my last line. It does not give any errors but my program does not work so I must not be correctly making the xDocument. Assiging an xml document directly to x2 like this
x2 = Xdocument.Load("chart.xml")
works.
But I need to do it through webclient. what am I doing wrong here