HtmlAgilityPack.HtmlNode no definition for SelectNodes

I am trying to use HtmlAgilityPack to search for elements inside a website. My problem is this:

I created a universal Windows 8 application (C #)

With the NuGet manager, I added:

using System.Net.Http; using HtmlAgilityPack; 

Then I did:

 string htmlPage; using (var client = new HttpClient()) { htmlPage = await client.GetStringAsync("http://www.domain.de/"); } HtmlDocument myDocument = new HtmlDocument(); myDocument.LoadHtml(htmlPage); //this line results an error @ "SelectNodes" var metaTags = myDocument.DocumentNode.SelectNodes("//meta"); 

But the visual studio says:

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

I was already looking for a problem, but all websites just solved another problem when the code said “DocumentElement” instead of “DocumentNode”.

Do you have any clues?

Thanks!

+5
source share
1 answer

Yes, SelectNodes not available in WP8, but you can use;

 var metaTags = myDocument.DocumentNode.Descendants("meta"); 

instead.

+8
source

Source: https://habr.com/ru/post/1210355/


All Articles