Please avoid using Nokogiri to parse untrusted input. If the input is XML maybe rexml can be used. Since I guess it's HTML and not XML, if REXML doesnt work here, please use just regular expressions to get the <title>.