Real nuby question.
This works fine…
irb> puts root.elements[‘foo/bar’].text
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
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?