[BUGFIX] Restore libxml error handler state after clearing

as advised here http://stackoverflow.com/a/7082487