Hi all,

I use the following to parse an XML file with REXML:

begin
	doc = REXML::Document.new File.new('test_cfg.xml')
rescue REXML::ParseException => msg
	puts "Failed: #{msg}"
end

When REXML throws ParseException, a whole load information is spilled 
into msg. Although this is useful for debugging, it hardly is an option 
for a "real-life" application that just has to notify the user of an 
error in his .xml file in the friendliest way possible.

How can I get just the "malformed XML: missing tag start" part (plus the 
line in the file) without all the stack trace and the information that 
comes after it, which for some reason is repeated twice. Is this 
possible without deconstructing the raised msg ?

P.S. generally REXML's error handling seems abysmal. Any simplest error 
(forgetting a = after attribute name, forgetting an opening element) 
throws an error for the last line in the .xml file


Thanks,
Eli

-- 
Posted via http://www.ruby-forum.com/.