I am following the example in http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-ruby.html?page=2
irb(main):003:0> doc = Document.new(File.new("bibliography.xml"))
irb(main):004:0> root = doc.root
irb(main):005:0> root.attributes['id']
irb(main):006:0> puts root.elements[1].elements["author"]
<author>
<firstname>Godfrey</firstname>
<surname>Vesey</surname>
</author>
I can do "root.attributes['id']="XXX""...
irb(main):007:0> puts root.attributes['id']
XXX
=> nil
Why cant i do root.elements[2].elements["author"].elements["firstname"]="YYY" ???
I would like to locate one of the elements and reassign the value. How can i do that?
irb(main):002:0> include REXML
irb(main):001:0> require 'rexml/document'