How to get a certain value in this XML file using XDocument?

delhi110009

New Member
\[code\]<item> <title>Lorem Ipsum</title> <media:group> <media:content url = "http://www.sample.com" rate = "0" /> <media:content url = "http://www.sample1.com" rate = "1" /> <media:content url = "http://www.sample2.com" rate = "2" /> </media:group></item>\[/code\]How do I get this value: \[quote\] http://www.sample2.com?\[/quote\]I tried using this code:\[code\]var query = from i in loadedData.Descendants("item") select new Site { Title = (string)i.Element("title"), Url = (string)i.Element(serv + "group").Elements(media + "content").Last() }; site = query.ToList();\[/code\]but the value of Url is "".I also have this:\[code\]private static readonly XNamespace media = "http://www.sampleX.com/";\[/code\]
 
Back
Top