Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Retreive ul, li tag which have not class of name.

$
0
0
Image
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;
        }
How to get of all ul tags in id 1-1.

Viewing all articles
Browse latest Browse all 655

Trending Articles