Hi,
this sounds simple but I just don't get it...
I want to replace the text child nodes of an REXML::Element by a new,
single text node...
In order to do that, I want to remove any previous text nodes first
---------------------------------
require 'rexml/document'
include REXML
doc = Document.new("<a> <b/> </a>")
a = doc.elements['a']
a.delete_element('b')
# assert: a.texts.size == 2
# try #1
#
# a.texts.clear
# --> can't modify frozen array (TypeError)
# try #2
#
# iterate all elements, call delete_element: fails, because
a.elements.size == 0
# MAGIC CODE GOES HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
a.text = "I am the only text in this element"
# assert a.texts.size == 1
---------------------------------
I don't think that setting all text nodes to zero-length string values
is a _good_ solution.
thanks for your help!
regards
peter