开发者

Cannot implicitly convert type 'System.Linq.IOrderedEnumerable<System.Xml.XPath.XPathNavigator>' to 'System.Xml.XPath.XPathNodeIterator'

开发者 https://www.devze.com 2023-03-03 10:54 出处:网络
I was wondering if anyone has an idea about the following error Cannot implicitly convert type \'System.Linq.IOrderedEnumerable\'

I was wondering if anyone has an idea about the following error

Cannot implicitly convert type 'System.Linq.IOrderedEnumerable' to 'System.Xml.XPath.XPathNodeIterator'

Here is the code generating the error.

var randomNodeset = from XPathNavigator node in nodeset
    orderby Guid.NewGuid()
    select nod开发者_JAVA技巧e;
return (XPathNodeIterator)randomNodeset;

Thanks for any help


There are two different sets of class for handling XML in .NET, the oldschool DOM-based classes and the new linq-to-xml classes. You're mixing them, which results in an incompatibility.

Here is an article on the differences between the two methods: http://dotbert.loedeman.nl/linq-to-xml-with-xpath

0

精彩评论

暂无评论...
验证码 换一张
取 消