2012-05-10 4 views
6

सभी XElement विशेषताओं के माध्यम से कैसे लूप करें और उनके मूल्य प्राप्त करें?सभी XElement विशेषताओं के माध्यम से लूप कैसे करें और उनके मान

foreach (SyndicationElementExtension extension in f.ElementExtensions) 
{ 
    XElement element = extension.GetObject<XElement>(); 

    // How to loop through all its attributes and get their values? 
} 

धन्यवाद! -

उत्तर

9

सरल Attributes() विधि का उपयोग करें:

foreach (var attribute in element.Attributes()) 
{ 
    string value = attribute.Value; 
    // ... 
} 
2

मान लिया जाये कि आप this question

var img2 = feeds.Items 
    .SelectMany(i => i.ElementExtensions 
         .Select(e => e.GetObject<XElement>().Attribute("url").Value) 
       ) 
    .ToArray(); 
को जवाब चाहिए
संबंधित मुद्दे