Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an XPath equivilent for Linq to XML?

I have been using Linq to XML for a few hours and while it seems lovely and powerful when it comes to loops and complex selections, it doesn't seem so good for situations where I just want to select a single node value which XPath seems to be good at.

I may be missing something obvious here but is there a way to use XPath and Linq to XML together without having to parse the document twice?

like image 889
Ryall Avatar asked Aug 18 '09 14:08

Ryall


1 Answers

You can still use XPath, with the XPathEvaluate, XPathSelectElement and XPathSelectElements extension methods. You can also call CreateNavigator to create an XPathNavigator.

like image 65
Jon Skeet Avatar answered Sep 18 '22 05:09

Jon Skeet