Cannot implicitly convert type 'System.Linq.IOrderedEnumerable<System.Xml.XPath.XPathNavigator>' to 'System.Xml.XPath.XPathNodeIterator'
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
精彩评论