'HtmlAgilityPack.HtmlNode' does not contain a definition for 'SelectNodes'

c# html-agility-pack selectnodes windows-phone

Question

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

I have setup config such as:

This is the code!!!

HttpClient client = new HttpClient();
        string html = await client.GetStringAsync(Url);
        HtmlDocument htmlDocument = new HtmlDocument();
        htmlDocument.LoadHtml(html);
        var a =htmlDocument.DocumentNode.SelectNodes("//p[@class='verse']");

Popular Answer

HAP version for Windows Phone doesn't expose SelectNodes() method due to lack of XPath support available for WP. You need to resort to use HAP LINQ API to do the same :

var a = htmlDocument.DocumentNode
                    .Descendants("p")
                    .Where(p => p.GetAttributeValue("class","") == "verse");



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why