Given an Html document with a structure similar to:
<html>
<head><title>HtmlDocument</title>
</head>
<body>
<div>
<span>Hello Span World</span>
<script>
Script Text
</script>
</div>
<ul class='relativeNav'>
<li>Hello </li>
<li>Li</li>
<li>World</li>
</ul>
</body>
</html>
The following XPath expression will select all nodes which are not script elements excluding all children of UL elements with class 'relativeNav':
var nodes = htmlDoc.DocumentNode.SelectNodes("//body//*[not(parent::ul[@class='relativeNav']) and not(self::script)]/text()");
Update: forgot to mention that if you need to exclude any children of ul[class='relativeNav'] irrespective of their depth you should use:
"//body//*[not(ancestor::ul[@class='relativeNav']) and not(self::script)]/text()"
If you wanted to exclude the ul element as well (somewhat irrelevant in the example above since the element does not contain text) you should specify:
"//body//*[not(ancestor-or-self::ul[@class='relativeNav']) and not(self::script)]"