A
aidy
Hi,
Using REXML, I am listing all the values of specific attributes from an
XML file
<SNIP>
require 'rexml/document'
include REXML # so ! pre-fixing everything with REXML
class Test_XML
def parse_file
doc = Document.new File.new('C:\Ruby_Files\TESTLOG.xml')
doc.elements.each("SAFS_LOG/LOG_MESSAGE") { |element| puts
element.attributes["type"] }
end
end
foo = Test_XML.new;foo.parse_file()
</SNIP>
output
START DATATABLE
GENERIC
START TESTCASE
Is it possible to only put those attributes with a specific value?
i.e.
puts if element.attributes["type"] == 'START TESTCASE '
Thanks
Aidy
Using REXML, I am listing all the values of specific attributes from an
XML file
<SNIP>
require 'rexml/document'
include REXML # so ! pre-fixing everything with REXML
class Test_XML
def parse_file
doc = Document.new File.new('C:\Ruby_Files\TESTLOG.xml')
doc.elements.each("SAFS_LOG/LOG_MESSAGE") { |element| puts
element.attributes["type"] }
end
end
foo = Test_XML.new;foo.parse_file()
</SNIP>
output
START DATATABLE
GENERIC
START TESTCASE
Is it possible to only put those attributes with a specific value?
i.e.
puts if element.attributes["type"] == 'START TESTCASE '
Thanks
Aidy