0
lotofxpath = arrayofmanyxpaths.map{|s| "\"" + s + "\""}.join(",")
puts lotofxpath #=> "/html/body/a[1]", "/html/body/a[2]"
newb = doc.xpath(lotofxpath).to_a
這將無法正常工作,並抱怨無效的xpath。nokogiri:無效的xpath?
然而,複製粘貼輸出字符串
newb = doc.xpath("/html/body/a[1]", "/html/body/a[2]").to_a
沒有問題會工作!
這裏發生了什麼事?