I'd recommend embracing Ruby's duck-typing approach. Your code shouldn't "care" if an object is a particular type. It should only "care" which methods it responds to.

If I swapped out your Nokogiri xml object for my own, custom object, this code would still work if it responded to the same messages.