Question

I'm trying to get HtmlAgilityPack to work with Windows 8 Metro Apps (Windows Store Apps). I've successfully written out all the code I need in a Windows Console App (C#) and it works perfectly for parsing the HTML I need and returning me the required string I need.

// Create a new HtmlDocument and load the incoming string
        HtmlDocument menu = new HtmlDocument();
        menu.OptionUseIdAttribute = true;
        menu.LoadHtml(response);

        HtmlNode nameToRemove = menu.DocumentNode.SelectSingleNode("//*[@id=\"maincontent_0_contentplaceholder_0_lblHall\"]");

My problem is with the DocumentNode.SelectSingleNode call. I'm getting the following error:

Error 2 'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectSingleNode' and no extension method 'SelectSingleNode' accepting a first argument of type 'HtmlAgilityPack.HtmlNode' could be found (are you missing a using directive or an assembly reference?)

I'm confirmed that I have all of the references setup the exact same way I did in the Console Application but am unable to get this to work. According to the HtmlAgilityPack twitter account, support for Windows 8 Metro/Windows Phone 8 was added in version 1.4.5. I'm double checked my NuGet Package Manager and I have 1.4.6 installed.

Is there something special that I need to do to select a node by XPath in an HtmlDocument in a Windows 8 App? Any suggestions would be highly appreciated.

Thanks!

Edit: Can anyone help me get the same results with a Linq query then. I'm not sure how I would go about it.

Was it helpful?

Solution

The Html Agility Pack relies on .NET for the XPATH implementation. Unfortunately, WinRT doesn't support XPATH, so you don't have anything related to XPATH in Html Agility Pack for WinRT.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top