Reputation: 10168
I know there are quite some threads talking about validating XML file against its XML schema, such as : validate-xml-using-libxml and xml-schema-validation-with-relaxng
So if there is a simple Perl module on CPAN that can test this with minimal code, then that would be very fantastic to know.
Upvotes: 3
Views: 6331
Reputation: 272337
You can simply use XML::Parser.
Note that your question title refers to being well-formatted (well-formed?) whereas the body refers to validation. If you want to validate (against a schema) check out XML::Validator::Schema.
Upvotes: 7
Reputation: 607
Since XML::Parser will die if a parsing error occurs, try this for minimal code:
XML::Parser->new->parse($xml);
Upvotes: 0
Reputation: 132858
There's XML::Compile, but it's not easy until you learn to use the module.
Upvotes: 1