0

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.

0

1 Answer 1

1

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]"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.