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

New Post: In loops Althought It be have data and no data(10 loops, 3 loops has data, the rest of loops has no data) but still return is null, Why?

$
0
0
I will explain by example. Note: When I debugged In 10 loops of foreach and I saw phrasal tag to get data or no data(10 loops, 3 loops has data, the rest of loops are no data). As the secondth of pictures It didn't get any the "pharse" in arrays that ends up return is null. It be give data into "arrays.Add(Dictionaries);" I want to get data as the firsth of picture. Here that results of pharse.
var title = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class","") =="def");
                    var examp = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def-body");
                    var hw = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "hw");
                    var prsgram = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "posgram");
                    var word = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "guideword");
                    var pharsel = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "phrase");
                    if(title!=null)
                    {
                        Dictionaries.Description = title.InnerText;
                    }
                    if(examp!=null)
                    {
                        Dictionaries.Examp = examp.InnerText;
                    }
                    if(hw!=null)
                    {
                        Dictionaries.Word = hw.InnerText;
                    }
                    if(word!=null)
                    {
                        Dictionaries.GuideWord = word.InnerText;
                    }
                    if(prsgram!=null)
                    {
                        Dictionaries.Grammar = prsgram.InnerText;
                    }
                    if(pharsel!=null)
                    {
                        Dictionaries.Phrase = pharsel.InnerText.Trim();

                    }

                    //Dictionaries.Description = title.InnerText;
                    //Dictionaries.Examp = examp.InnerText;
                    //Dictionaries.Word = hw.InnerText;
                    //Dictionaries.GuideWord = word.InnerText;
                    //Dictionaries.Grammar = prsgram.InnerText;
                    Dictionaries.Symbol = "/Photos/glasses-50.png";
                    //Dictionaries.Phrase=pharsel.InnerText;
                    arrays.Add(Dictionaries);
Image
Image

Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>