I am trying to evaluate 4 XML files that I create from a mysql database, I want to output the text of those XML field as a pairs of data so I can create a hash. (Ex: "Total Builds, 359") I am pretty sure I am getting a syntax error because of the way I am using the block
Here is what I am trying to do:
while i < numberOfFiles do
#create a document
doc = Document.new(File.new(filenames[i]))
doc.elements.each("//row/field")
{
|e| ##Syntax error here
name = e.attributes['name']
text = e.text
if name == "Total Builds"
puts name + ", " + text
elsif name == "Successful Builds"
puts name + ", " + text
elsif name == "Failed Builds"
puts name + ", " + text
else
puts text.join(",")
end
}
I know that the format of this block is wrong, but is there a way to do something similar to this in ruby?
Thanks