Dharmesh Rupani Dharmesh Rupani - 4 years ago 104
Ruby Question

Ruby - unable to write using nokogiri

I am searching a

element by its classname and want to add it next to other
element. Following code is not writing data what I get using doc1.search .

require 'nokogiri'

doc1 = Nokogiri::HTML(File.open("overview.html"))
affixButtons = doc1.search('div.margin-0-top-lg.margin-10-bottom-lg.text-center')

Can someone suggest what I'm missing ?

Answer Source

You're not saving your resulting HTML to file, you can do it like so:

File.open("result.html", "w"){|f| f.write(doc1.to_html)}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download