检索没有名称类的ul,li标签

时间:2015-03-04 03:31:17

标签: c# html-agility-pack

如何获取所有<li>代码?显示的代码只显示1行<li>标记。

string id="1-1";
public async void ExampLoad(string id)
{
    var httpClient = new HttpClient();
    string srtHtml = await httpClient.GetStringAsync("http://dictionary.cambridge.org/dictionary/british/appeal");
    var htmlDoc = new HtmlDocument();
    htmlDoc.LoadHtml(srtHtml);

    List<Models.EnglishDictionary> arrays = new List<Models.EnglishDictionary>();
    var NewListNodeHtml = htmlDoc.GetElementbyId("entryContent");
    if(NewListNodeHtml!=null)
    {
        var SenseBlock = NewListNodeHtml.Descendants("div").Where(x => x.GetAttributeValue("id", "") == id);
        if(SenseBlock!=null)
        {
            foreach(var node in SenseBlock)
            {
               Dictionaries = new Models.EnglishDictionary();
               var ul = node.Descendants("div").FirstOrDefault(x => x.GetAttributeValue("class", "") == "extraexamps");
               if(ul!=null)
               {
                   Dictionaries.Examp = ul.InnerText.Trim();
               }
               arrays.Add(Dictionaries);
             }
         }
     }
     lstExample1_1.ItemsSource = arrays;
}

我发布照片的意义不足。

此处链接照片:

https://social.msdn.microsoft.com/Forums/getfile/617918

0 个答案:

没有答案