How to get the contents of a HTML element using HtmlAgilityPack in C#?

后端 未结 2 871
轻奢々
轻奢々 2021-01-18 18:58

I want to get the contents of an ordered list from a HTML page using HTMLAgilityPack in C#, i have tried the following code but, this is not working can anyone help, i want

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 19:02

    How about:

    var el = (HtmlElement)doc.DocumentNode
        .SelectSingleNode("//ol");
    if(el!=null)
    {
        string s = el.OuterHtml;
    }
    

    (untested, from memory)

提交回复
热议问题