0

I have an XPath query that looks like this, with both single and double quotes. How do I escape the apostrophe properly so that the query works?

I tried:

rating<- getNodeSet(doc1,"//*[(@id = "taplc_location_reviews_list_apd_0")]//*[contains(concat( " ", @class, " " ), concat( " ", "ui_bubble_rating", " " ))]" 

How can I use this Xpath so that I'm able to scrape rating from Tripadvisor?

It's giving an error:

Error: unexpected symbol in "rating<- getNodeSet(doc1,"//*[(@id = "taplc_location_reviews_list_apd_0"

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Jul 23 '18 at 07:20

1 Answers1

0

Try replacing the double quotes inside the xpath to single quotes (but leave the double quotes around the xpath), like so:

rating<- getNodeSet(doc1,"//[(@id = 'taplc_location_reviews_list_apd_0')]//[contains(concat( ' ', @class, ' ' ), concat( ' ', 'ui_bubble_rating', ' ' ))]"
stevec
  • 41,291
  • 27
  • 223
  • 311