There is a site from which I need to take a news block and bring them to the ListView. I read that it is better to do this with the help of HtmlAgilityPack.

page = new HtmlDocument(); page.LoadHtml(address); IEnumerable<HtmlNode> news = page.DocumentNode.Descendants("div").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("news")); 

And then I do not know what to do.

Here is the code from the site.

 <ul class="news"> <li class="dotes"> <div class="nimg"><a href="http://radio.aplus.by/news/1394-festivalnyj-sezon-k-pop-kultury-hallyu.html"><img src="http://radio.aplus.by/uploads/news/thumbs/1470812232_afisha.jpg" alt=""></a><span class="ramka">&nbsp;</span></div> <div class="ntext"><span class="date">10.08.2016</span> <a href="http://radio.aplus.by/news/1394-festivalnyj-sezon-k-pop-kultury-hallyu.html" class="ntitle">Фестивальный сезон... <a href="http://radio.aplus.by/news/1394-festivalnyj-sezon-k-pop-kultury-hallyu.html#comments" class="comments">Комментарии (0)</a></div> <div class="clrr"></div> </li> ........................... и так далее................... </ul> 

I understand that first you need to take the news class itself, then for each dotes (there are always 10 of them) you need to take classes inside it and then take information from them. How to display such data in Listiew I know. But how can I get data from these classes until I can figure it out.

I would understand a little the principle of all this or some good examples of working with the Html Agility Pack.

  • I would recommend using some kind of service, such as import.io. There you can configure the parsing of any site and get the necessary data on a convenient REST-API. - Ilya Bizunov
  • No, this does not suit me. The application for the Windows store is and do not want to depend on the service. - Morgomirius
  • Then maybe the site itself provides an API for getting news? Or RSS. - Ilya Bizunov
  • In general, everything turned out. Only one problem remained. The <div ... </ div> tag has its own tags, and after them comes text that is not selected by any tags, that is, implicitly specified. How to get it? Chrome shows that it is an object (text), but it cannot be received in the code. - Morgomirius
  • Try something like .InnerText - Ilya Bizunov

0