类似于XPath: How to match attributes that contain a certain string但不使用 XPath。是否可以?
<c BarFoo="val1">
<d Foo="val2" someAttribute="">
<e FooBar="val3" />
</d>
</c>
基本上我想选择文档中所有属性名称包含“Foo”的属性值,所以它应该返回值“BarFoo”,“FooBar”,“Foo”(va1,val2,val3)
最佳答案
像这样:
elem.DescendantsAndSelf().Attributes().Where(a => a.Name.LocalName.Contains("Foo"))
关于c# - 如何使用 LINQ 选择 XML 文档中包含特定字符串的所有属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2796386/