aidy
5/5/2006 11:44:00 AM
Hi,
> If you provide the XML (or a short sample) we might be able to help a
> bit better.
This is a sample of the XML.
<SNIP>
<SAFS_LOG>
<LOG_MESSAGE type="START TESTCASE" date="04-05-2006" time="16:43:42" >
<MESSAGE_TEXT><![CDATA[ST_LTD_1]]></MESSAGE_TEXT>
</LOG_MESSAGE>
<LOG_MESSAGE type="FAILED" date="04-05-2006" time="16:44:08" >
<MESSAGE_TEXT><![CDATA[TerritoryListTable:innerText did not
contain substring]]></MESSAGE_TEXT>
</LOG_MESSAGE>
<LOG_MESSAGE type="STOP TESTCASE" date="04-05-2006" time="16:44:05" >
<MESSAGE_TEXT><![CDATA[ST_LTD_1]]></MESSAGE_TEXT>
</LOG_MESSAGE>
...... many more sections like this
</SAFS_LOG>
</SNIP>
The XML that I am dealing with is not well structured. I tried to XSLT
it, but I started pulling my hair out.
So I thought using REXML to parse and builder to create a new XML file,
then XSLT it.
So what I am trying to do is this (pseudo code)
if type_attribute = "START TESTCASE"
puts gettext() # i.e. ST_LTD_1
end
if type_attribute = "FAILED"
@fail = 'FAILED'
puts 'FAIL!"
end
if attribute = "STOP TESTCASE" && @fail != 'FAILED'
puts 'PASS'
end
> Btw, you're not closing the file handle properly. Rather do this:
> oc = File.open('C:\Ruby_Files\TESTLOG.xml') {|io| Document.new(io)}
I was under the impression that if a file had an adjacent block, Ruby
automatically closes it.
I am not so sure where this block would go '{|io| Document.new(io)}'?
Thanks for the Help
Aidy