Currently I am dealing with an HtmlDocument in c# from a website:
return doc.DocumentNode.SelectSingleNode("//span[@title=input]").InnerText;
I want to get the inner text from a span with the title "input". Above is my current code but I receive a NullReferenceException when trying to run it. What should my implicit parameter be in order to retrieve the text from "input"?
return doc.DocumentNode.SelectSingleNode("//span[@title='"+input+"']").InnerText;
Because input is not a string, it has to be concatenated to fit the parameters. Thanks for all of you help!
You have to delimit strings with quotes in XPath expressions:
return doc.DocumentNode.SelectSingleNode("//span[@title='input']").InnerText;
Plain input
will try to match a node by that name and substitute its value.