The accepted answer above is correct, however, it has the disadvantage that it will go through the whole XML file, even if it finds a <title> at the beginning.
I had similar needs, and I ended up writing a saxy ruby stone that is designed to be effective in such situations. Under the hood, it implements the Nokogiri SAX Api.
Here's how you use it:
require 'saxy' title = Saxy.parse(path_to_your_file, 'title').first
It will stop when it detects the first occurrence of the <title> .
source share