#!/usr/bin/ruby require 'xml/simple' # When a closure is used, then the changes are written back to the disk # When a string as second or third paramter is provided, then a empty # xml file is created if it not exists (no mather if a closure is used or not) # XML::Simple.open(FILE,LOCKTIMEOUT,STRING) {} ... set timeout for lock file and create file if !exists? # XML::Simple.open(FILE,LOCKTIMEOUT) {} ... set timeout for lock # XML::Simple.open(FILE,STRING) {} ... create file if !exists? # XML::Simple.open(FILE) {} ... just open file change and write back (LOCKTIMEOUT defaults to 7) XML::Simple.open(File.dirname($0) + "/EXAMPLE.tmp.xml","") { |doc| node = doc.root.append_child("element",Time.now) } # Print the document puts XML::Simple.open(File.dirname($0) + "/EXAMPLE.tmp.xml")