I want parse xml in windows store app with Xdocument.
I tried this,but returned with null:
XDocument xDoc;
string title= "";
xDoc = XDocument.Load(url);
var elements = from x in xDoc.Descendants()
select new
{
title = x.Descendants("title").First().Value,
};
foreach (var el in elements)
_title = title;
Xml contents:
<title type='text'>tiitle</title>
<content type='text'> gfgdgdggd</content>
<link rel='related' type='application/atom+xml' href='http....'/>
How can is retrive text from attributes ?
As ZevSpitz already mentioned, your XML is invalid. I modified it a bit to be able to test my code:
You can retrieve values from the
typeattributes with the following code:In my case
xmlis declared as follows:You can still use your code to load the XML from a URL if the file contents are the same.