我希望获取包含命名空间http://www.my.com/
中属性的所有元素代码:
IEnumerable<XElement> list1 =
from el in RootElement.DescendantsAndSelf()
//where it contains attributes from http://www.my.com/ - how?
select el;
答案 0 :(得分:2)
验证属性名称的namespace part:
XNamespace my = "http://www.my.com/";
IEnumerable<XElement> list1 =
from el in xdoc.Root.DescendantsAndSelf()
where el.Attributes().Any(attr => attr.Name.Namespace == my)
select el;