title: Removing element by class name with HTMLAgilityPack c#
body: <p>I'm using the html agility pack to read the contents of my html document into a string etc. After this is done, I would like to remove certian elements in that content by their class, however I am stumbling upon a problem.</p>
  
  <p>My Html looks like this:</p>
  
  <pre><code>&lt;div id="wrapper"&gt;
      &lt;div class="maincolumn" &gt;
          &lt;div class="breadCrumbContainer"&gt;
              &lt;div class="breadCrumbs"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;div class="seo_list"&gt;
              &lt;div class="seo_head"&gt;Header&lt;/div&gt;
          &lt;/div&gt;
  
  Content goes here...
  &lt;/div&gt;
  </code></pre>
  
  <p>Now, I have used an xpath selector to get all the content within the  and used the InnerHtml property like so:</p>
  
  <pre><code>            node = doc.DocumentNode.SelectSingleNode("//div[@id='wrapper']");
              if (node != null)
              {
                  pageContent = node.InnerHtml;
              }
  </code></pre>
  
  <p>From this point, I would like to remove the div with the class of "breadCrumbContainer", however when using the code below, I get the error: "Node "" was not found in the collection"</p>
  
  <pre><code>            node = doc.DocumentNode.SelectSingleNode("//div[@id='wrapper']");
              node = node.RemoveChild(node.SelectSingleNode("//div[@class='breadCrumbContainer']"));
  
              if (node != null)
              {
                  pageContent = node.InnerHtml;
              }
  </code></pre>
  
  <p>Can anyone shed some light on this please? I'm quite new to Xpath, and really new to the HtmlAgility library.</p>
  
  <p>Thanks,</p>
  
  <p>Dave</p>