How to loop through all XElement attributes and get their values

c#, xml, xpath

Solution

Simple - use the `Attributes()` method:

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

Problem

How to loop through all XElement attributes and get their values? ``` foreach (SyndicationElementExtension extension in f.ElementExtensions) { XElement element = extension.GetObject<XElement>(); // How to loop through all its attributes and get their values? } ``` Thank you!

Original source

Related problems