Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>the better way to remove a node from their parent in <code>HtmlAgilityPack</code> is this:</p> <pre><code>nodeToRemove.ParentNode.RemoveChild(nodeToRemove); </code></pre> <p>In your code you can use like this:</p> <pre><code>List&lt;MediNetScheme&gt; medinetScheme = new List&lt;MediNetScheme&gt;(); HtmlDocument htdoc = new HtmlDocument(); htdoc.LoadHtml(results); foreach (HtmlNode table in htdoc.DocumentNode.SelectNodes("//table[@class='list-medium']/tbody[1]/tr[@class]")) { string itemValue = string.Empty; HtmlNode ansvarig =table.SelectSingleNode("//table[@class='list-medium']/tbody[1]/tr[@class]/td[4]"); ansvarig.ParentNode.RemoveChild(ansvarig); itemValue = table.InnerText; medinetScheme.Add(new MediNetScheme(){Datum=itemValue.Remove(15),Sections=itemValue.Remove(0,15)}); } MediNetScheme.ItemsSource = medinetScheme; </code></pre> <p>I hope this will be useful for you :)</p> <p>EDITED: Do you want to get the InnerText of the three first td's in each row. I'm checking your code and i think that xpath inside the foreach is wrong. </p> <p>I would change the xpath for a classic counted loop with linq like this:</p> <pre><code>foreach (HtmlNode trNodes in htdoc.DocumentNode.SelectNodes("//table[@class='list-medium']/tbody[1]/tr[@class]")) { string itemValue = string.Empty; int position = 1; foreach (var td in tr.DescendantNodes("td")) { itemValue = td .InnerText; medinetScheme.Add(new MediNetScheme(){Datum=itemValue.Remove(15),Sections=itemValue.Remove(0,15)}); position++; if (position == 3) break; } </code></pre>
    singulars
    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.
    1. VO
      singulars
      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