title: XPath "Not". Ignore branches with a specific tag
body: <p>I have loaded a web page into the HTML Agility Pack and have a DOM.  I want to use XPATH to pull out all of the text on the page (but not the javascript found within <code>&lt;script&gt;</code> tags).</p>
  
  <p>I figure I need a //text() and then a 'not' to ignore any tag within the branch that has a <code>&lt;script&gt;</code> in it.</p>
  
  <p>I have tried</p>
  
  <pre><code>doc.DocumentNode.SelectNodes("//text()[not(self::script)]"))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>doc.DocumentNode.SelectNodes("//text()[not(script)]"))
  </code></pre>
  
  <p>but neither work. An example of the XPath property of a node that they return is (notice the Script)</p>
  
  <pre><code>/html[1]/body[1]/div[2]/div[4]/div[1]/div[1]/div[1]/div[3]/script[1]/#text[1]
  </code></pre>
  
  <p>I have consulted with both of these posts.</p>
  
  <p><a href="https://stackoverflow.com/questions/2265526/is-it-possible-to-do-not-matching-in-xpath">Is it possible to do &#39;not&#39; matching in XPath?</a> </p>
  
  <p><a href="https://stackoverflow.com/questions/4182594/grab-all-text-from-html-with-html-agility-pack">Grab all text from html with Html Agility Pack</a> (This is a good post but it brings out the JS)</p>
  
  <p>Any suggestions?</p>