Syed
Syed

Reputation: 187

How to handle double quotes in xpath

I have a XPATH:

"//*[@id='TEST_0'][disabled=""]"

But I am getting error at the end ") required". Is there a way we can handle double quotations with in xpath?

Upvotes: 2

Views: 12207

Answers (5)

Michael Kay
Michael Kay

Reputation: 163262

Why not just write

"//*[@id='TEST_0'][disabled='']"

It only starts to be a problem when you need both double and single quotes.

Upvotes: 2

fahad
fahad

Reputation: 389

you can do it this way

"//*[@id='TEST_0'][disabled="\""\"]"

Example :

System.out.print("\"Hello\"");

This will print: "Hello" in double qoutes

Upvotes: 0

Leon Barkan
Leon Barkan

Reputation: 2703

Best way to do it:

@"//*[@id='TEST_0'][disabled=""]"

Upvotes: 0

Syed
Syed

Reputation: 187

Thanks for you suggestion. It did work

("//*[@id='Test_0'][disabled=" + "\"\"" + "]");

Upvotes: 0

Saifur
Saifur

Reputation: 16201

That's actually related to language you are using. Use (\) escape character

Upvotes: 2

Related Questions