CsQuery to parse a collection of li items

我怕爱的太早我们不能终老 提交于 2019-12-03 16:05:07

This is done in order to keep CsQuery consistent with jQuery which behaves the same way. You can convert it back to a CQ object by calling the .Cq() method as such

foreach (var li in items)
{
    var newTournament = false;
    var test = li.Cq().Find("header h2");
}

Or if you'd like more jQueryish syntax, the following also works:

foreach (var li in items)
{
    var newTournament = false;
    var test = CQ.Create(li)["header h2"];
}

Your code, could be re-factored to the following if you'd like:

var texts = CQ.Create(htmlString)[".blog-accordion li header h2"]
              .Select(x=>x.Cq().Text());
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!