I'm currently trying to get "Output" from below
<ul class="breadcrumb" data-campaign="Header">
<li>
<a data-medium="Menu-KhoaHoc" href="/khoa-hoc" title="Khoa hoc">Khoa hoc</a>
</li>
<li>
<a data-medium="Menu-TinTuc" href="/khoa-hoc/tin-tuc" title="Tin tuc">Output</a>
</li>
</ul>
So far, I only managed to get
private static async Task<string> Category(string? url)
{
string stringInsert = "";
await Task.Run(() =>
{
var html = new HtmlWeb()
{
AutoDetectEncoding = false,
OverrideEncoding = Encoding.UTF8
};
HtmlAgilityPack.HtmlDocument doc = html.Load(url);
stringInsert = doc.DocumentNode.Descendants("ul").First(item => item.Attributes.Contains("data-campaign") && item.Attributes["data-campaign"].Value == "Header").InnerText;
});
return stringInsert;
}
//This returns a value of "Khoa hocOutput"
I tried using Skip(1).First() but the output is the same. Using ElementAt(1) returns OutOfIndexExeption.
This is my first time working with Html so I dont know anyway to get the desired result. I'm also required to NOT using Xpath in my code
