lotofxpath = arrayofmanyxpaths.map{|s| "\"" + s + "\""}.join(",")
puts lotofxpath #=> "/html/body/a[1]", "/html/body/a[2]"
newb = doc.xpath(lotofxpath).to_a
这将不起作用,并抱怨无效的 xpath。
但是,复制粘贴输出字符串
newb = doc.xpath("/html/body/a[1]", "/html/body/a[2]").to_a
将毫无问题地工作!!!
这里发生了什么?