Hi Alex,

I puzzled about this for a while. Eventually I found this in the docs for
XML::Error (http://libxml.rubyforge.org/rdoc/classes/LibXML/XML/Error.html)

> By default, warnings, errors and fatal errors that libxml generates are
printed to STDERR via the XML::Error::VERBOSE_HANDLER proc.

> To disable this output you can install the quiet handler:

>     XML::Error.set_handler(&XML::Error::QUIET_HANDLER)

> Install your own handler:
>     XML::Error.set_handler do |error|
>        puts error.to_s
>     end

> Or remove all handlers:
>     XML::Error.reset_handler

So we've been using something a bit like the second method mentioned
above as we are trying to capture some sort of informative error
message about
what went wrong with the parsing to return the user.

Think there are some more examples in the test class for the error
handler (tc_error.rb) if you have a look at the source.

regards

sam


2009/4/23 Alex Wayne <a...@beautifulpixel.com>

> I am parsing a whole of imperfectly formed HTML.  In doing so, about
> 1600 errors are generated and dumped to the log/console every time I
> parse this feed.  Yet it parses fine with the recover option.  But the
> options for supressing the messages don't appear to work.
>
> Here's my code:
>
> parser = LibXML::XML::HTMLParser.string(Downloader.get
> (url).clean_html,
>  :options => LibXML::XML::HTMLParser::Options::RECOVER |
>    LibXML::XML::HTMLParser::Options::NOERROR |
>    LibXML::XML::HTMLParser::Options::NOWARNING)
> page = parser.parse.root
>
>
> Is this the right way to declare the options for supressing errors and
> warnings?  Why aren't they actually supressed.  I would worry too much
> about this normally, but it appears after some profiling it appears
> printing and handling these errors takes about 20-40% of my total
> request time in my rails app, so its a fairly large performance issue.
> _______________________________________________
> libxml-devel mailing list
> libxml-devel@rubyforge.org
> http://rubyforge.org/mailman/listinfo/libxml-devel
>
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to