print XML::LibXML->get_last_error; #### eval { $doc->validate; }; if ($@) { print "Doc not valid: $@\n"; } else { print "Doc valid\n"; }