如何从 HTML 获取所有标题元素? HTML敏捷包,C#

How to get all title elements from HTML? HTMLAgilityPack,C#

正在处理解析器音乐网站。需要在播放列表中获取有关歌曲的更多信息。 在使用 AngleSharp 之后,我使用了 HTMLAgilityPack。 所以,歌曲的标题位于,例如:

        <div class="datagrid-cell cell-artist">
<div class="ellipsis"><a class="datagrid-label datagrid-label-main" itemprop="byArtist" title="Drake" href="/ru/artist/246791">Drake</a></div></div>

但是用我的代码,我无法获得我需要的属性。 代码(使用):

 class Program
{
    static async Task Main(string[] args)
    {

        HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
        var client = new HttpClient();
        string html = await client.GetStringAsync("https://www.deezer.com/ru/playlist/2872124702");
        document.LoadHtml(html);
        if (document.DocumentNode != null)
        {

            foreach (HtmlNode node in document.DocumentNode.Descendants("div").Where(d =>
            d.Attributes.Contains("class") && d.Attributes["title"].Value.Contains("ellipsis")))
            {
                string title = node.SelectSingleNode(".//a").Attributes["title"].Value; //I think - need InnerText
                Console.WriteLine(title);
            }

求助,我不知道该怎么做。 祝你好运!

我在评论中的建议似乎有效, 在此处查看工作版本:https://dotnetfiddle.net/h8OrbG

    using System;

public class Program
{
    public static void Main()
    {
        var doc = new HtmlAgilityPack.HtmlDocument();
        var html = "<div class='datagrid-cell cell-artist'><div class='ellipsis'><a class='datagrid-label datagrid-label-main' itemprop='byArtist' title='Drake' href='/ru/artist/246791'>Drake</a></div></div>";
        doc.DocumentNode.AppendChild(HtmlAgilityPack.HtmlNode.CreateNode(html));
        foreach (var node in doc.DocumentNode.SelectNodes("//a[@itemprop='byArtist']"))
        {
            Console.WriteLine(node.Attributes["title"].Value);
        }
    }
}