You should use a relative XPath expression, that is, relative to your el
context node
HtmlAgilityPack.HtmlNode el = htmlDoc.DocumentNode.SelectSingleNode("(//div[@class='TableContainer'])[" + index + "]");
if (el != null)
{
foreach (HtmlNode node in el.SelectNodes(".//text()"))
{
Debug.WriteLine("text=" + node.InnerText.Replace(" ", " "));
}
}
"//text()"
will select all descendant text nodes of the document root node
See Location Paths and Abbreviated Syntax from XPath specifications for details.
//para
selects all the para descendants of the document root and thus selects all para elements in the same document as the context node
.//para
selects the para element descendants of the context node