Friday 15 August 2014

c# - Why cant I grab attribute value of this node -


This is the code that I am trying to:

  var items = xdoc Descendants "Items"). Select (item = & gt; new {MyImage = (string) item.Ellements ("enclosure"). Select (i => i.Attribute ("url").) .SingleOrDefault ()}) .list For making();   

Here's how this looks in the XML file:

  & lt; Item & gt; & Lt; Enclosure url = "http://ep00.epimg.net/politica/imagenes/2013/06/22/actualidad/1371899226_298900_1371917547_miniatura_normal.jpg" length = "6409" type = "picture / jpeg" /> & Lt; / Item & gt;  

post-text "itemprop =" text ">

Change

  MyImage = (string) item. Elements ("enclosure"). Select (i = & gt; i.Attribute ("url"). Value) .SingleOrDefault ( MyImage = (string) items. Element ("enclosure"). Attribute ("url"). Value    

/ Pre>

If you do not want to check the blank, you can try it and write it:

  MyImage = item.Get ("enclosure / url" , "");    

No comments:

Post a Comment