Take the 2-minute tour ×  lotofxpath = arrayofmanyxpaths.map{|s|
"\"" + s + "\""}.join(",")  puts lotofxpath #=>
"/html/body/a[1]", "/html/body/a[2]"   newb =
doc.xpath(lotofxpath).to_a  this will not work, and complain
about invalid xpath.  however, copying pasting the output string
newb = doc.xpath("/html/body/a[1]", "/html/body/a[2]").to_a
will work without problems!!!  what is happening here ?
share|improve this question add comment  1 Answer  up vote 1
down vote accepted  In the first case you end up calling
Nokogiri as follows  newb = doc.xpath("\"/html/body/a[1]\",
\"/html/body/a[2]\"").to_a  and this is not the right Ruby
syntax to accomplish what you are trying to do. The right way is
newb = doc.xpath(*arrayofmanyxpaths).to_a share|improve this
answer add comment  Your Answer