Skip to content

Instantly share code, notes, and snippets.

@dedeibel
Created October 27, 2009 16:21
Show Gist options
  • Save dedeibel/219693 to your computer and use it in GitHub Desktop.
Save dedeibel/219693 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
if (@ARGV != 2) {
print "$0 <xml file> <schema file>\n";
exit 1;
}
my $url = $ARGV[0];
my $xsd = $ARGV[1];
print "Validating: $url with $xsd\n";
my $doc = XML::LibXML->new->parse_file($url);
my $xmlschema = XML::LibXML::Schema->new(location => $xsd);
eval { $xmlschema->validate($doc); print "Dokument okay.\n"; };
if ($@) {
print "Dokument has errors: $@\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment