my $dom = XML::LibXML->load_html( string => $code, recover => 1, # try to recover parse errors and carry on to produce a DOM suppress_errors => 1, # turn off the error output );