From: dblack@... Date: 2003-05-03T06:02:13+09:00 Subject: Re: chomp'ing REXML:Element.text Hi -- On Sat, 3 May 2003, Andreas Schwarz wrote: > Hello, > > I'm using the following code to read and chomp the content of a few > elements from REXML. The problem is that I get an exception when an > element is empty () because .text returns nil then. > How can I solve this problem without writing large if-constructions? > > @company = customer.elements["company"].text.chomp > @salutation =customer.elements["salutation"].text.chomp You could throw in a to_s: ....text.to_s.chomp (since nil.to_s is "") David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav