title: Getting InnerText ignoring script node by using Html Agility Pack in C#
body: <p>I have following page from which I want to get a list of proxy servers from a table:</p>
  
  <blockquote>
    <p><a href="http://proxy-list.org/spanish/search.php?search=&amp;country=any&amp;type=any&amp;port=any&amp;ssl=any" rel="nofollow noreferrer">http://proxy-list.org/spanish/search.php?search=&amp;country=any&amp;type=any&amp;port=any&amp;ssl=any</a></p>
  </blockquote>
  
  <p>Each row in the table is an ul element. My problem is when obtaining the first li element which associated class is "proxy" from the ul element. I want to obtain the IP and Port so I perform an InnerText but as li element has an script child node, it returns the text of the script node.</p>
  
  <p>Below an image of the structure of the page:</p>
  
  <p><a href="https://i.stack.imgur.com/qN6q3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qN6q3.png" alt="enter image description here"></a></p>
  
  <p>I have tried below code using Html Agility Pack and LINQ:</p>
  
  <pre><code>WebClient webClient = new WebClient();
  string page = webClient.DownloadString("http://proxy-list.org/spanish/search.php?search=&amp;country=any&amp;type=any&amp;port=any&amp;ssl=any");
  
  HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
  doc.LoadHtml(page);
  
  List&lt;List&lt;string&gt;&gt; table = doc.DocumentNode.SelectSingleNode("//div[@class='table']")
              .Descendants("ul")
              .Where(ul =&gt; ul.Elements("li").Count() &gt; 1)
              .Select(ul =&gt; ul.Elements("li").Select(li =&gt;
                  {
                      string result = string.Empty;
                      if (li.HasClass("proxy"))
                      {
                          HtmlNode liTmp = li.Clone();
                          liTmp.RemoveAllChildren();
                          result = liTmp.InnerText.Trim();
                      }
                      else
                      {
                          result = li.InnerText.Trim();
                      }
                      return result;
                  }).ToList()).ToList();
  </code></pre>
  
  <p>I can obtain a list which each item is a list containing the fields (Proxy, País, Tipo, Velocidad, HTTPS/SSL) but field proxy is always empty. Also I am not getting at all the "País" and "Ciudad" columns.</p>