i'm working on an windows 8 metro apps and i'm working on VS Ultimate.
i succeded to get the XML on a webpage and i wanna parse it with LINQ to XML. when i do it with a local xml file, it is working but when i use the one i downloaded it is not. i tryed to debug it by printing the xml i got and it is correct. i think this is because of the asyncronous method we use to get the xml, the parsing start before the end of the extraction. is someone having a solution for me ? i checked a lot on internet but nothing was really helful. the code :
XDocument loadedData = new XDocument();
List<Data> listeData = new List<Data>();
var httpResponse = await new HttpClient().GetAsync("http://api.allocine.fr/rest/v3/search?partner=YW5kcm9pZC12M3M&filter=movie,person&count=1&page=1&q=avatar&format=xml");
string sourceCode = await httpResponse.Content.ReadAsStringAsync();
XDocument doc = XDocument.Parse(sourceCode);
listeData = (from query in doc.Descendants("movie")
select new Data {
OriginalTitle = (string) query.Element("originalTitle"),
Title = (string) query.Element("title"),
ProductionYear = (string) query.Element("productionYear"),
Cover = (string) query.Element("cover"),
Resume = (string) query.Element("resume")
}).ToList();
var group1 = new SampleDataGroup("Group-1", "Tous Mes Films", "", "Assets/icone_groupe_all_movies.jpg",
"Films sur le DD");
foreach (Data dataList in listeData) {
group1.Items.Add(new SampleDataItem("Group-1-Item-1", dataList.Title, "", dataList.Cover, "",
dataList.Resume, group1));
}
this.AllGroups.Add(group1);
thank you so much guys !