Document.documentnode.selectnodes ul id threads li tolist hướng dẫn

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

serdam55 opened this issue

Apr 21, 2018

· 10 comments

Assignees

Comments

I just start to write a new application with Net Core 2.0 and I have this structure:

the ConsoleApp import the Library reference that is a dll, and Library import HtmlAgilityPack 1.8.0 that's actually the last version available.

When I run the ConsoleApp, I get this error:

Unhandled exception of type 'System.IO.FileNotFoundException' in Library.dll Could not load file or assembly 'HtmlAgilityPack, Version=1.8.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a'. The specified file could not be found.

The file is available, as you can see in the image:

Document.documentnode.selectnodes ul id threads li tolist hướng dẫn

The text was updated successfully, but these errors were encountered:

Hello @serdam55 ,

I just tried the v1.8.0 from NuGet and everything works fine.

I believe your issue may be more related to some weird NuGet issue we get sometimes.

  • Make sure you have the latest NuGet packages manager
  • Close & re-open the solution may work sometime

There is not so much we can do on our side for this kind of issue since it's not related directly to the library.

Let me know if one of these solutions worked.

Best Regards,

Jonathan

Hello @serdam55 ,

We have released the v1.8.1.

Perhaps we had an issue on our side with a file assembly that we forgot to update the version.

Let me know if that's working with the newest version.

Best Regards,

Jonathan

@JonathanMagnan

Yes, now is fixed! Thank you for this amazing library!! :)

Could I ask a question here? It's ot, well I try, anyway, suppose I have the following list:

  • foo
  • foo3 ...

    how can I get the first a tag for each li? I tried using:

    HtmlNodeCollection compsLi = doc.DocumentNode .SelectNodes("div[@id='page_match_1_block_competition_left_tree_2']//div//ul/li[1]");

    but this return null, the result should be: foo, foo3

    Thanks again :)

    Hello @serdam55 ,

    Here is an example to get you started to get the first a tag for every li.

    var html1 = @"

    "; var doc1 = new HtmlAgilityPack.HtmlDocument(); doc1.LoadHtml(html1); var nodes = doc1.DocumentNode.SelectNodes("//div[@id='page_competition_1_block_competition_left_tree_2']/div/ul/li/a[1]").ToList();

    Hope that helped ;)

    Best Regards,

    Jonathan

    What about using the ul class name then?

    var nodes = doc1.DocumentNode.SelectNodes("//ul[@class='left-tree']/li/a").ToList();
    

    @JonathanMagnan well I also get 2018/2019 if I use this:

    HtmlNodeCollection compsLi = compsDiv.SelectNodes("div//ul[@class='left-tree']//li//a");

    Of course you will get 2018/2019,

    Look at the number of slash between my string and your ;)

    var nodes = doc1.DocumentNode.SelectNodes("//ul[@class='left-tree']/li/a").ToList();
    

    0 has not the same behavior as

    var nodes = doc1.DocumentNode.SelectNodes("//ul[@class='left-tree']/li/a").ToList();
    

    1. Using two slashes will check from the root instead of the current element.

    HtmlNodeCollection compsLi = compsDiv.SelectNodes("//ul[@class='left-tree']/li/a");

    @JonathanMagnan you're indeed right! Thanks for the support. What's the difference against "/" and "//"? Are this things available in the documentation? I not able to find that, thanks again :)

    We are currently writing some

    var nodes = doc1.DocumentNode.SelectNodes("//ul[@class='left-tree']/li/a").ToList();
    

    2 documentation. It will be available in around 2 months probably.