Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml Agility Pack SelectSingleNode giving always same result in iteration?
    primarykey
    data
    text
    <p>I would like the nodes in the collection but with iterating SelectSingleNode I keep getting the same object just node.Id is changing... What i try is to readout the webresponse of a given site and catch some information like values, links .. in special defined elements.</p> <pre><code>int offSet = 0; string address = "http://www.testsite.de/ergebnisliste.html?offset=" + offSet; HtmlWeb web = new HtmlWeb(); //web.OverrideEncoding = Encoding.UTF8; HtmlDocument doc = web.Load(address); HtmlNodeCollection collection = doc.DocumentNode.SelectNodes("//div[@itemtype='http://schema.org/Posting']"); foreach (HtmlNode node in collection) { string id = HttpUtility.HtmlDecode(node.Id); string cpname = HttpUtility.HtmlDecode(node.SelectSingleNode("//span[@itemprop='name']").InnerText); string cptitle = HttpUtility.HtmlDecode(node.SelectSingleNode("//span[@itemprop='title']").InnerText); string cpaddress = HttpUtility.HtmlDecode(node.SelectSingleNode("//span[@itemprop='addressLocality']").InnerText); string date = HttpUtility.HtmlDecode(node.SelectSingleNode("//div[@itemprop='datePosted']").InnerText); string link = "http://www.testsite.de" + HttpUtility.HtmlDecode(node.SelectSingleNode("//div[@class='h3 title']//a[@href]").GetAttributeValue("href", "default")); } </code></pre> <p>This is for example for 1 iteration:</p> <pre><code>&lt;div id="66666" itemtype="http://schema.org/Posting"&gt; &lt;div&gt; &lt;a&gt; &lt;img /&gt; &lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;div class="h3 title"&gt; &lt;a href="/test.html" title="Test"&gt; &lt;span itemprop="title"&gt;Test&lt;/span&gt; &lt;/a&gt; &lt;/div&gt; &lt;div&gt; &lt;span itemprop="name"&gt;TestName&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt; &lt;span itemprop="address"&gt;Test&lt;/span&gt; &lt;/div&gt; &lt;span&gt; &lt;a&gt; &lt;span&gt;&lt;!-- --&gt;&lt;/span&gt; &lt;span&gt;&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;div itemprop="date"&gt; &lt;time datetime="2013-03-01"&gt;01.03.13&lt;/time&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p></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.
 

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