I am trying to get an information from the web (adress
in my code) with HtmlAgilityPack in C#, but I have to wait until the <div class="center fs22 green lh32">
is loaded on the page.
var url = $"https://www.webpage.com/test{info}";
var web = new HtmlWeb();
var doc = web.LoadFromBrowser(url, html =>
{
return !html.Contains("<div class=\"center fs22 green lh32\"></div>");
});
string adress = doc.DocumentNode
.SelectSingleNode("//td/span[@id='testedAddress")
.Attributes["value"].Value;
Unfortunally I always get this error when I start my code : Translation : 'Unclosed chain.'
How can I pass this error ?
The error occurs on the following line:
.SelectSingleNode("//td/span[@id='testedAddress")
There is a '
and a ]
missing at the end of that XPath expression. That inner part incompletely enclosed in '
is the "chain" (actually, a string in English, or "chaîne de caractères" in French) the error message is talking about.
So, the line should read instead:
.SelectSingleNode("//td/span[@id='testedAddress']")