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"> </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.
.InnerText
- Ilya Bizunov