Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

validating xml with perl

by Johnd (Initiate)
on Mar 18, 2012 at 19:50 UTC ( [id://960310]=perlquestion: print w/replies, xml ) Need Help??

Johnd has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to validate the below xsd http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd with this xml : http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-recent.xml using XML::LibXML::Schema and get an error message using the below code :

my $schema = XML::LibXML::Schema->new(location =>$xsd); my $parser = XML::LibXML->new; my $doc = $parser->parse_file($xml); eval { $schema->validate( $doc ) }; if ( my $ex = $@ ) { return $ex; } return; }

and get an error message that the schema is error could someone tell why this validation is end with error and if i need to revisit my code for this validation to end with success?

Replies are listed 'Best First'.
Re: validating xml with perl
by tangent (Parson) on Mar 18, 2012 at 20:38 UTC
    Can you post the full error message. I tried the code below and got no errors.
    use XML::LibXML; my $xsd = 'http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd'; my $xml = 'http://static.nvd.nist.gov/feeds/xml/cve/nvdcve-2.0-recent. +xml'; my $schema = XML::LibXML::Schema->new(location =>$xsd); my $parser = XML::LibXML->new; my $doc = $parser->parse_file($xml); eval { $schema->validate( $doc ) }; if ( my $ex = $@ ) { print $ex; } else { print "Schema validated ok"; } # OUTPUT Schema validated ok
      here is the error message i get: Schemas parser error : Failed to locate the main schema resource at 'http://nvd.nist.gov/schema/nvd-cve-feed_2.0.xsd'
        It seems like you're not even getting as far as retrieving the xsd file from the remote server. Can you normally retrieve files over the internet using Perl?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://960310]
Approved by tobyink
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-24 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found