我有一个XPath查询,它带有单引号和双引号。如何正确转义撇号以使查询有效?
我尝试过:
rating<- getNodeSet(doc1,"//*[(@id = "taplc_location_reviews_list_apd_0")]//*[contains(concat( " ", @class, " " ), concat( " ", "ui_bubble_rating", " " ))]"
如何使用此Xpath,以便能够从Tripadvisor抓取评分?
出现错误:
错误:“评级<-getNodeSet(doc1,“ // * [(@ id =” taplc_location_reviews_list_apd_0“
答案 0 :(得分:0)
尝试将xpath中的双引号替换为单引号(但在xpath周围保留双引号),如下所示:
rating<- getNodeSet(doc1,"//[(@id = 'taplc_location_reviews_list_apd_0')]//[contains(concat( ' ', @class, ' ' ), concat( ' ', 'ui_bubble_rating', ' ' ))]"