Re: rexml exceptions



On Tue, Sep 30, 2008 at 9:59 AM, Mark Thomas <mark@xxxxxxxxxxxxxx> wrote:
Out of curiosity, I tried libxml. It has nice error messages:

foo.xml:3:
parser error :
Opening and ending tag mismatch: title line 3 and txitle
<title>Foo</txitle>
^

but they go to stdout. You can capture them by registering an error
handler. Sample code:

parser = XML::Parser.new
parser.filename = "foo.xml"

msgs = []
XML::Parser.register_error_handler lambda { |msg| msgs << msg }

begin
parser.parse
rescue Exception => e
puts "Error: #{msgs}"
end

Interesting. I was thinking about doing libxml anyway. I do not like REXML.

Thanks.

-- Mark.

-- rakaur

.