Skip to content

Instantly share code, notes, and snippets.

@skreuzer
Created August 9, 2010 13:59
Show Gist options
  • Save skreuzer/515446 to your computer and use it in GitHub Desktop.
Save skreuzer/515446 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use XML::Parser;
use strict;
if(!@ARGV) {
print STDERR "Give me a file to parse.\n";
exit 1;
}
my $xml_file = shift @ARGV;
my $parser = XML::Parser->new(ErrorContext=>2);
eval { $parser->parsefile($xml_file); };
if($@) {
$@ =~ s/at \/.*?$//s;
print STDERR "\nError in $xml_file:\n$@\n";
exit 1;
} else {
print "$xml_file is well formed\n";
}
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment