Validating XML against DTD with Perl???

I have a program that generates XML files and I want
to do some automated testing.

Ideally, I'd like to use perl to validate the XML files created
against a DTD.

Is there any perl module that can do this easily??


I am aware of XML::Parser module from CPAN, however
this can not validate XML against a DTD (its built
on top of a non-validating parser (expat).
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There are a few options that I can think of:

HTML::Validator is beta but does dtd-based validation. Furthermore, it lets you override the DTD definition to use your own file if you wish.

You could write a C++ app using one of the many toolkits that you called from your Perl code. I haven't checked IBM's xml4c recently ( but it did support DTD-validation although it didn't give you much control over this functionality - pass or fail.

There are command-line SGML parsers that you could call. One you might want to look at is:

Also, I did a quick check at CPAN and saw XML::ESISParser which indicates that it does DTD-based validation. It looks like it just uses the command-line XML validator mentioned above, providing some convenient interfaces for you as a perl programmer.

You may also want to peek at libxml-enno for XML:Checker and XML:DOM:ValParser. I think these are alpha.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.