c#, HtmlAgilityPack: Can someone please explain why this xpath grabs top of page and not a child element?
Using the attached webpage I'm trying to grab the text highlighted i dark blue below.
However, because I will also be grabbing all the other data below it, I am first grabbing the element highlighted in yellow as the starting point which is:
//h3 [text()='Business Details']/../following-sibling::div
If I add this to the above xpath I can get the text I want:
/div[1]/div/div [text()]
However, if I do this in 2 steps in c# the same path grabs something at the top of the page. Here's my code
static void BusDetailsTest()
{
HtmlDocument doc = new HtmlDocument();
doc.Load(@"D:\Apps\VSOCD\LeadaRator\Trunk\V01\WpfBrowserTest\SampleSourceFiles\5-5.2 Number19.txt");
// Get the outer element that can be used as a starting point for all the other pieces of data to scape also.
var h3 = doc.DocumentNode.SelectSingleNode("//h3 [text()='Business Details']/../following-sibling::div");
// Why does this grab something at the top of the page rather than some nexted child divs?
var divBusDesc = h3.SelectSingleNode("//div[1]/div/div");
Console.WriteLine(divBusDesc.InnerText);
}
Can someone please explain what I'm doing wrong and how to correct it?
Thank you
I tried to upload a text file with the page source but this site is real buggy today and wont allow attaching text files.