Html Agility Pack: SelectSingleNode and XPath are not available on Xamarin Forms platform

html-agility-pack xamarin xamarin.forms xpath


I need to discover a method to use Xpath or HTML Selectors to locate an object from an HTML file.

I'm attempting to utilize XPath since selectors are not supported by HTML Agility Pack.

Unfortunately, it seems that Xamarin Forms does not support SelectSingleNode(string somexpathvalue). There is no definition of it in HTMLNode.

I discovered in NuGet that System.Xml.XPath is not installed. I encounter a mistake when I attempt to execute it:

Severity Code Description Project File Line Suppression State Error Could not install package 'System.Xml.XPath 4.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0

Can SelectSingleNode be used without System.XML.Xpath?

5/22/2016 9:41:40 AM

Popular Answer

No, System.Xml.XPath does not have a version for Xamarin. Html Agility Pack (HAP) XPath support depends on the.NET XPath implementation provided in System.Xml.XPath*. Forms.

If you presently utilize the portable Xamarin.Forms project strategy, your alternatives may be to create XPath-dependent capabilities in the respective platform-specific projects or to do the query using the LINQ API of HAP rather than XPath. I think that most, if not all, XPath queries can be converted to LINQ queries.

Answer from HAP's creator:

**) Linq is used by HTML Agility Pack for the Windows Phone 8.1 platform. is an example of an XPath to LINQ conversion.

5/23/2017 12:08:01 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow