如何遍历所有XElement属性并获取其值

Dev*_*per 6 c# xml xpath

如何遍历所有XElement属性并获取其值?

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

    // How to loop through all its attributes and get their values?
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

Jon*_*eet 11

简单 - 使用Attributes()方法:

foreach (var attribute in element.Attributes())
{
    string value = attribute.Value;
    // ...
}
Run Code Online (Sandbox Code Playgroud)