my $t= XML::Twig->new(load_DTD => 1,DTDHandler=>\&checkit )->parsefile( "$xmlfile"); sub checkit { my ($twig, $dtd) = @_; my $root=$twig->root; my @text=$root->att_names; if (grep /schemaLocation/, @text) { print "found schema\n"; } else { if ($twig->{twig_doctype}) { print "found dtd\n"; } else { print "no dtd/schema defined\n" } } }