I
I
Ivan Vyrov2015-11-16 06:40:01
C++ / C#
Ivan Vyrov, 2015-11-16 06:40:01

Where can I read the Html Agility Pack documentation?

Good afternoon!
Please tell me where you can read the Html Agility Pack documentation in Russian or good lessons (examples)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MonkAlex, 2015-11-16
@MonkAlex

In theory, the main thing is to be able to build XPath expressions.
With them it is very easy to get any information that is at least somehow typed, for example:

var pageNodes = document.DocumentNode.SelectNodes("//div[@id=\"pagination_related\"]//a");
            if (pageNodes != null)
            {
              foreach (var node in pageNodes)
                pages.Add(new Uri(this.Uri + node.Attributes[0].Value));
              pages = pages.Distinct().ToList();
            }

From what is not obvious - to request data inside a node, you must use a dot before the xpath:
var chapterNodes = document.DocumentNode.SelectNodes("//div[@class=\"related_info\"]");
          if (chapterNodes != null)
          {
            foreach (var node in chapterNodes)
            {
              var link = node.SelectSingleNode(".//h2//a");
              var desc = node.SelectSingleNode(".//div[@class=\"related_tag_list\"]");
              chapters.Add(new Chapter(new Uri(this.Uri, link.Attributes[0].Value), desc.InnerText));
            }
          }

A
Andrey Danilov, 2015-11-16
@Danand

The class reference is on the pages of the NuDoq project - in fact, a convenient display of XML documentation from the NuGet Html Agility Pack.
A very brief and, perhaps, slightly outdated overview of some features of the Html Agility Pack (on the other hand, in Russian) is on Habré.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question