Should I subclass XML::Parser?

No, that kind of approach is deprecated these days.

If you want access to the XML contents as an event stream (like XML::Parser's Handler interface) then the best option would be to use SAX. Your code would use XML::SAX::ParserFactory to get an object capable of parsing XML. This object might use XML::SAX::PurePerl, XML::LibXML::SAX, XML::SAX::Expat or something else depending on what was installed on the target machine. These parser modules are all written to the SAX API so you don't need to worry about which one you get.

On the other hand, if you'd prefer to access the XML contents as a DOM tree then once again XML::Parser would not be the best answer. XML::Parser's Tree interface is not really an object model and certainly not DOM compliant. XML::DOM uses XML::Parser to provide a DOM level 1 API but a better bet would be either XML::LibXML or XML::GDOME which provide DOM level 2 APIs (XPath and namespace support being the key bits you want). Whether you'd subclass these modules or simply use them is up to you.

You may find the Perl XML FAQ useful.


In reply to Re: How to implement XML languages by grantm
in thread How to implement XML languages by gildir

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.