Hello Daniweb,

I have a list of words seperated by line breaks in a .txt file. It looks like this.

driving
drop
dry
dust
ear
early
earth
east
edge
education


I need to figure out the easiest way to convert it to a simple XML file that looks like this:

<?xml version="1.0" encoding="utf-8" ?>  
<Data>  
  <Words>  
    <Word>east</Word>  
    <Word>edge</Word>  
    <Word>education</Word>  
  </Words>
</Data>

Is there a standard way of doing something like this? Or will I need to write my own program to handle this functionality. It seems to me like there should already be a tool out there that already does this.

I perfer ruby
http://www.ruby-lang.org/de/downloads/

load module xml rexml

require "rexml/document"
include REXML
file = File.new("mydoc.xml" ,"w")
doc = Document.new()
doc << XMLDecl.new(1.0, "utf-8", "no")
doc.add_element(Element.new("DATA"))
w = Element.new( "Words")
File.open("demo.data") do |filedata|
  while filedata.gets
    e = Element.new( "Word")
    e.add_text Text.new($_.chomp)
    w.add_element(e)
  end
end
doc.root.add_element(w)
doc.write( file,0 )
file.close