Validating XML in Perl with libxml and an XSD file
问题 I am trying to have my perl script get an Xxml file from online and validate it according to an XSD file. The code to do this is as follows: my $url = shift @ARGV; my $response = $ua->get($url) || die "Can't fetch file"; my $file = $response->content; my $schema_file = "schema.xsd"; my $schema = XML::LibXML::Schema->new(location => $schema_file); my $parser = XML::LibXML->new; my $doc = $parser->parse_string($file); eval { $schema->validate($doc) }; die $@ if $@; Running this results in a