Split text by Xpath.C# HtmlAgilityPack
See the question and my original answer on StackOverflowYou can get all texts that follow a BR after a DividerText like this (in a sample console app):
HtmlDocument doc = new HtmlDocument();
doc.Load(MyTestHtm);
foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//text()[contains(., 'DividerText:')]/following-sibling::br/following-sibling::text()"))
{
Console.WriteLine(node.InnerText.Trim());
}
Will dump this out:
TextToSelect1
TextToSelect2
TextToSelect3
TextToSelect4
The XPATH expression first gets recursively a text() node that contains a specific 'DividerText:' token, then get all following siblings BR elements, than gets all following sibling text elements.