DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Ruby XML I18n File Parser
// Ruby script to help parse a XML file
require 'rexml/document'
include REXML
englishFile = File.new('englishFileName', 'w+')
spanishFile = File.new('spanishFileName', 'w+')
portugueseFile = File.new('portugueseFileName', 'w+')
errorMessagesFile = File.new("errorMessages.xml")
document = Document.new(file)
root = document.root
root.each_element("Property") do |propertyTag|
id = propertyTag.attributes['id']
propertyTag.each_element("element") do |elementTag|
elementAttr = elementTag.attributes['otherTag']
error = elementTag.text == nil ? "" : "#{id} = #{elementTag.text}\n"
if elementAttr = "pt"
portugueseFile << error
elsif elementAttr == "es"
spanishFile << error
else
portugueseFile << error
end
end
end
errorMessagesFile.close()
englishFile.close()
spanishFile.close()
portugueseFile.close()





