Writing xml

Hi

I am having a problem with writing xml file. I am using REXML.
Everything goes fine on IRB, i can add new elements to my existing file,
add atributes or text. When i print my xml in IRB it looks ok. Then i
try xml.write(STDOUT, 0), and i get no errors but the xml does not
change. My persmissions look ok. I am working on windows XP. Any clue?

Phlip wrote:

Stop using IRB and start using unit tests. You should write a little bit
of
a test case and ‘p’ a result, then run ‘rake recent’ and read your
console.
If the result is correct, write an assertion that locks it in and
repeat.
Small experiments with test cases will replace small experiments with
IRB,
and will preserve a history of correct results. This is how RoR itself
was
created, and it’s a major reason RoR is so powerful.

thanks for the information! i really need to start using tests then, but
first i will read a little about them.

Pabloz wrote:

I am having a problem with writing xml file. I am using REXML.
Everything goes fine on IRB,

Stop using IRB and start using unit tests. You should write a little bit
of
a test case and ‘p’ a result, then run ‘rake recent’ and read your
console.
If the result is correct, write an assertion that locks it in and
repeat.
Small experiments with test cases will replace small experiments with
IRB,
and will preserve a history of correct results. This is how RoR itself
was
created, and it’s a major reason RoR is so powerful.

i can add new elements to my existing file,
add atributes or text. When i print my xml in IRB it looks ok. Then i
try xml.write(STDOUT, 0), and i get no errors but the xml does not
change. My persmissions look ok. I am working on windows XP. Any clue?

STDOUT is your console’s handle as a file stream. It’s not a real file.
Try
this:

File.open(‘foo.xml’, ‘w’) {|f| xml.write(f, 0) }


Phlip
Redirecting... ← NOT a blog!!!

Hi –

On Wed, 29 Nov 2006, Phlip wrote:

Pabloz wrote:

I am having a problem with writing xml file. I am using REXML.
Everything goes fine on IRB,

Stop using IRB and start using unit tests.

Well… the world is a big place, and there’s room for lots of things
:slight_smile: I agree with James Duncan Davidson that the Rails application
console is a great debugging tool, and I’d say the same about irb in
general. So are unit tests, of course :slight_smile:

David


David A. Black | [email protected]
Author of “Ruby for Rails” [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB’s Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] Ruby for Rails | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org

On 29 Nov 2006, at 15:54, Pabloz wrote:

thanks for the information! i really need to start using tests
then, but
first i will read a little about them.

You may like to watch the latest Peepcode screencast on test-first
development called, well, Test-First Development:

http://peepcode.com/articles/2006/11/26/test-first-development

Regards,
Andy S.