0

I am working on a Nokogiri::XML::Document object and when I see t using puts , it is reflecting the change but the same change is not reflected in the xml file with which it is related.

doc = Nokogiri::XML(File.open("d.xml"))

#Modification in doc.....
puts doc 
#changes are reflected

but when I open d.xml, no changes

Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
Learner
  • 59
  • 8

1 Answers1

0
doc = Nokogiri::XML(File.read("d.xml"))

puts doc.to_xml

# or

File.open("new_d.xml", 'w') do |file|
    file.write( doc.to_xml )
end
Astockwell
  • 1,498
  • 13
  • 11