Select element with given attribute using linq to xml -


i've got following xml structure:

<artists>     <artist>          <name></name>          <image size="small"></image>          <image size="big"></image>      </artist> </artists> 

i need select name , image given attribute (size = big).

var q = c in feed.descendants("artist")         select new { name = c.element("name").value,                       imgurl = c.element("image").value }; 

how can specify needed image attribute(size=big) in query above?

it's quite simple when know how!

var artistsandimage = in feed.descendants("artist")                       img in a.elements("image")                       img.attribute("size").value == "big"                       select new { name = a.element("name").value                                  , image = img.value}; 

this return names , big images artists.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -