54Sandgroper
3/27/2006 12:14:00 PM
Real nuby question.
This works fine...
irb> puts root.elements['foo/bar[3]'].text
three
I can't work out how to do this...
irb> i = 3
irb> puts root.elements['foo/bar[i]'].text
I keep getting error message
NoMethodError: undefined method `text' for nil:NilClass
I've tried defining "i" every which way -- [i], [@i] and others.
irb> $i = 3
irb> [${i}]
doesn't error, but it outputs as if i = 1.
All of the REXML examples for text nodes that I have been able to track
down have the index hard coded, or use .each
Can someone point me in the right direction?