How to use XPath with XElement or LINQ?

To use XPath with LINQ to XML add a using declaration for System.Xml.XPath, this will bring the extension methods of System.Xml.XPath.Extensions into scope.

In your example:

var value = (string)xml.XPathEvaluate("/response/data/hash");

Leave a Comment