Sure it could be issue. Here is possible solution:
unless searchablefile.at_xpath("//h1[contains(text(), 'pvda')]").nil?
sheet[row,column] = searchablefile.at_xpath("//h1[contains(text(),
'pvda')]").content
end
2012/9/11 Sybren Kooistra <[email protected]>
> Alright, perfect. It works.
>
> However, many variables that I create are based on the POSSIBILITY that
> a certain xpath/string exists in a file. If it doesnt, it should
> preferably return a nil or a 'no'.
>
> By using at_xpath and then .content, if an xpath (for example pvda =
> searchablefile.at_xpath("//h1[contains(text(), 'pvda')]") returns
> nothing, the variable.content (in this case sheet1[row,1] =
> pvda.content) does not work, and it no longer runs the rest of the code
> (error = undefined method 'content' for nil:nilClass (NoMethodError)
>
> How can I work around this and/or save boolean on the basis of xpath?
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
-- You received this message because you are subscribed to the Google Groups
ruby-talk-google group. To post to this group, send email to
[email protected]. To unsubscribe from this group, send email
to [email protected]. For more options, visit this
group at https://groups.google.com/d/forum/ruby-talk-google?hl=en