In article <slrnbb5ftt.2cv.usenet / home.andreas-s.net>,
Andreas Schwarz  <usenet / andreas-s.net> 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 (<element></element>) 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 can use a rescue e.g.

  @salutation =customer.elements["salutation"].text.chomp rescue ''

but there may be better ways of doing it.

Hope this helps,

Mike
-- 
mike / stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       | GPG PGP Key      1024D/059913DA 
mike / exegenix.com                  | Fingerprint      0570 71CD 6790 7C28 3D60
http://www.exegenix.com/           |                  75D2 9EC4 C1C0 0599 13DA