First of all it would help if you would say what parser you use...

Secondly, as a general note to your (general) title: validating XML with Perl is a bit tricky. It depends for instance what level of validation you want to perform. Most of the Perl solutions support validation using DTD's. This gives you only (very) limited possibilities for validating your XML documents. DTD's were the first attempt for validating XML documents and IMHO not a very good one. There are certain disadvantages using DTD's

Several schema languages were designed to counter these problems (Schematron, relaxng). The most popular and best supported is W3C XML Schema. It is safe to say this isn't exactly perfect either but many of the issues with DTD's were more or less solved. XML Schema gives you much more power to validate documents at the cost of added complexity, i.e. XML Schema is not simple, there is a learning curve. Furthermore I know of no Perl solution that fully supports XML Schema, as I recall it only subsets are supported. Depending on what you want to do this might work for you. I have my own set of tools to work with XML, if I would have to pick a Perl solution it would probably be XML::Xerces but I'm biased towards Xalan/Xerces.

NB In the course of time some very clever/tricky solutions were devised to counter the problems with DTD's, e.g. adding datatypes but it never worked out that well.

Cheers,

Harry


In reply to Re: xml validation using perl by dHarry
in thread xml validation using perl by pavanmach

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.