1

我希望从命名空间http://www.my.com/中获取所有包含属性的元素

编码:

   IEnumerable<XElement> list1 =
                    from el in RootElement.DescendantsAndSelf()
                    //where it contains attributes from http://www.my.com/ - how?
                    select el;
4

1 回答 1

2

验证属性名称的命名空间部分:

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;
于 2012-12-24T11:58:41.513 回答