Paradise Regained
Jacques Distler: In theory, the result of serializing a REXML tree is well-formed XML.
begin
require 'rexml/document'
foo = REXML::Document.new("<div>a�b</div>")
bar = REXML::Formatters::Default.new
out = String.new
bar.write(foo, out)
puts out
rescue REXML::ParseException => e
puts e.continued_exception.message
end
It is quite possible to produce a DOM that can’t be serialized into well-formed XML, but I do agree that if one parses a document without error, one should be confident that the document produced by serializing that document is well-formed.
With this ticket fixed, the above code now produces:
Illegal character '�' in raw string "a�b"