REXML and doc.write to a file

A

aidy

Hello,

I have written some XML that outputs well to a stream

doc.write($stdout, 1)
=>
<testresults>
<test id='ST_MSE_3'>
<pass>PASS</pass>
</test>
</testresults>

However, I am trying to write the output to a file

doc.write(File.open("C:\test_results.xml","w"))

but no file is created.

Thanks for the help

Aidy
 
K

Kenosis

Any chance you need to escape your blackslash in the file path? If so,
and you're not, you could be creating a strange file perhaps in the
current directory: your path reads c:\t..., which would escape the 't'.
I don't have a windows box at hand to try if for you. Hope this
helps.

Ken
 
R

Robert Klemme

Also, rather do

File.open("C:\\test_results.xml","w") {|io| doc.write io}

to ensure proper closing of the file. (This might btw also be the
reason why you don't see the file contents being written.)

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,985
Messages
2,570,199
Members
46,766
Latest member
rignpype

Latest Threads

Top