This code reads an xml file, modifys an element and saves the file locally.
require 'net/http' require 'rexml/document' url = 'http://www.example.com/journal080907.xml' element_name = ARGV[0] # basic_category xpath = ARGV[1] # eg.'entries/entry' file = ARGV[2] # eg. 'journal080907.xml' element_value = ARGV[3] # 'ruby' file = File.new(file,'w') # get the XML data as a string xml_data = Net::HTTP.get_response(URI.parse(url)).body # extract event information doc = REXML::Document.new(xml_data) docx = doc node = docx.elements[xpath] element = node.elements[element_name] puts element.text element.text = 'ruby' file.puts docx