require 'rexml/document' include REXML file = File.new("xmlfile.xml") doc = Document.new(file) doc.elements.each("protocol/role") { |r| r.attributes["name"] doc.elements.each("protocol/role/states/state") { |s| puts " typedef int[0,2] state" + r.attributes["name"] + "; const state" + r.attributes["name"] + s.text + " = ; const state" + r.attributes["name"] + " " + s.text } #" typedef int[0,2] state" + r.attributes["name"] + "; const state" + r.attributes["name"] + s.text + } # doc.elements.each("protocol/role") { # |e| puts " typedef int[0,1] msgs" + e.attributes["name"] + "; const msgs" + e.attributes["name"] #} }} #for i in 0..1 # doc.elements.each("protocol/role/rule/pre/state") { # |e| puts e.text } #puts "= #{i}" #end #}