#!/usr/bin/ruby require 'xml/simple' # When a closure is used, then the changes are written back to the disk XML::Simple.open(File.dirname($0) + "/EXAMPLE.xml") { |doc| node = doc.root.find("/test/names/name")[0] node.text = Time.now } # Print the document puts XML::Simple.open(File.dirname($0) + "/EXAMPLE.xml")