module Hpricot

def xs(str)

XML escaped version of to_s
def xs(str)
  str.to_s.unpack('U*').map {|n| xchr(n)}.join # ASCII, UTF-8
rescue
  str.to_s.unpack('C*').map {|n| xchr(n)}.join # ISO-8859-1, WIN-1252
end