I am downloading an XML file from a site I created and it works fine on the emulator; however, it doesn't work at all on the phone. It comes back with a web exception error and an IO error...and the error property from the HttpsCompleted event says error the remote server returned an error. File not Found. BUT this works on my emulator.
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
WebClient wc = new WebClient();
wc.DownloadStringCompleted += HttpsCompleted;
wc.DownloadStringAsync(new Uri("http://.../SessionInfo.xml"));
}
private void HttpsCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XDocument doc = null;
string results = null;
if (e.Error == null)
{
XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);
List<XElement> xelem = xdoc.Root.Elements() as List<XElement>;
results = e.Result;
var sessions = from x in xdoc.Descendants("Session")
select new
{
ID = x.Descendants("ID").First().Value,
TITLE = x.Descendants("Title").First().Value,
TIME = x.Descendants("Time").First().Value,
DESCRIPTION = x.Descendants("Description").First().Value
};
foreach (var wd in sessions)
{
sessionsList.Add(new Session(wd.ID, wd.TITLE, wd.TIME, wd.DESCRIPTION));
Debug.WriteLine("Session ID is {0}, Title is {1}, Time is {2}", wd.ID, wd.TITLE, wd.TIME);
}
}
SessionInfoList.ItemsSource = sessionsList;
XML Looks like:
<request><Session><ID>1234-1234-1234-1234</ID><Title>Session Title</Title><Time>10:00AM-11:30AM</Time><Description>Some description.</Description></Session></request>