SHARE
TWEET

Untitled

a guest Dec 29th, 2010 23 Never
  1.     a = []
  2.     document.xpath("//script").each do |elem|
  3.       a << elem.text
  4.     end
  5.     # remove all text
  6.     document.xpath("//text()").remove()
  7.     # restore script text
  8.     i = 0
  9.     document.xpath("//script").each do |elem|
  10.       elem.content = a[i] # restore script texts
  11.       i += 1
  12.     end
RAW Paste Data
Top