require 'rexml/document'
str = File.readlines('myxml.xml').join # '<a></a>'
el = REXML::Document.new str
p el.to_s # "<a/>"
I want <a></a>
instead of <a />
.
How can I get this with rexml in ruby?
Since it’s an XML, the elements got collapsed unless there is a [possibly emply] node nested:
el.root.add_text ''
el.to_s
#⇒ "<a></a>"