I'm writing a function to scrape data from a website using xpath strings like this:
//*[@id="mw-content-text"]/div/table[1]/tbody/tr[14]
As Obvious, when I assign this string to a variable I get a syntax error due to the presence of the quotation marks. I already know some ways to manually correct the text and avoid errors. My question is if there's a way to put the text into a variable "as it is". Thanks in advance.
There is no problem at all assigning this string to a variable "as is". E.g. write the string(s) into a table and read it from a recordset.
But if you want to hard-code the string in your VBA source code, you need to escape the quotes by duplicating them.
Const xPath As String = "//*[@id=""mw-content-text""]/div/table[1]/tbody/tr[14]"