c# how to read xml attributes with xelement

Frayx picture Frayx · May 19, 2011 · Viewed 13.6k times · Source

I have a XML with this string:

<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-tMQm4zsM-Yg/TdFEfG2y7GI/AAAAAAAAAT0/XGyQ8vFdVwY/s72-c/moorea-view.jpg" height="72" width="72" />

how can I read the attribute "url" with XElement?

Answer

Stecya picture Stecya · May 19, 2011

Use Attribute method

yourxElement.Attribute("url").Value;