Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML Agility Pack: DocumentNode.Descendants() returns null values
    primarykey
    data
    text
    <p>I am using HTML Agility Pack to scrape websites for my Windows Store app. The version for Windows 8 store apps does not support XPath nor does it have a selectNodes function, but it does support lambda expressions to look up the values needed. </p> <p>After extensively searching the web the only solution I see (over and over again) is to use DocumentNode.Descendants() to get back a list of elements to search within. However, for me, DocumentNode.Descendants() always returns back null values. This happens whether or not I pass in a parameter to the function. </p> <p>I am getting back a response though. I can see the html for the page inside of the HtmlDocument object. </p> <p>Code Snippet:</p> <pre><code>HttpContent loginContent = new FormUrlEncodedContent(new[] { new KeyValuePair&lt;string, string&gt;("name", username), new KeyValuePair&lt;string, string&gt;("password", password) } HttpResponseMessage response = await httpClient.GetAsync(httpClient.BaseAddress); //Gets the cookie response = await httpClient.PostAsync(loginPageAddress, loginContent); //Logs in HtmlDocument doc = new HtmlDocument(); doc.Load(new StringReader(await response.Content.ReadAsStringAsync())); // Loads doc, can see html for the page in doc.text attribute now HtmlNode pointsNode = doc.DocumentNode.Descendants("div").Where(o =&gt; o.Attributes["class"].Value == "availableNumber").FirstOrDefault(); // fails because Descendants returns null values </code></pre> <p>From debugging in my immediate window:</p> <pre><code>doc.DocumentNode.Descendants("div") {HtmlAgilityPack.HtmlNode.Descendants} name: null System.Collections.Generic.IEnumerator&lt;HtmlAgilityPack.HtmlNode&gt;.Current: null System.Collections.IEnumerator.Current: null </code></pre> <p>Any help solving this issue will be greatly appreciated! Thanks all.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload