I cannot really recommend XML::DOM at this time.

It might be standard, robust and widely used, but it is not supported anymore (Enno seems to have disappeared from the surface of the Earth) and it is difficult to install, as the latest version is hidden in a bundle (libxml-enno), and has not been updated to be compatible with XML::Parser.

This could improve in the near future as it looks like someone has volonteered to take over its maintenance (although destroying compatibility with older versions of XML::Parser in the process).

Beyond the hopefully temporary lack of support, XML::DOM is not only ugly, I also think it is dangerous. The level of the API is so low that using the DOM directly results in code that can be broken really easily.

A good example is that you cannot go simply from an element node to the next one. If there is a comment before the element you want the getNextSibling method will happily return it to you. Of course it is easy to write a getNextElement method, and even to add an extra parameter so you can specify the tag of the element you want, but then you end up using a non-standard API and, from the examples I see floating around the web, I don't think too many people go through that trouble. I am fairly sure that most DOM code that does not use an extra (non-standard) layer of methods on top of the standard ones are vulnerable to inserting (legal) XML comments in the documents.

The fact that the only practical way to access elements is the getElementsByTagName also means that it is used everywhere in a DOM program, despite being really inefficient.

I have not used XML::XPath but I would think that it is better designed than the DOM, better supported than XML::DOM, and more efficient as it now uses a C library for managing nodes.


In reply to Re: Re: Re: Sanctifying Modules by mirod
in thread Sanctifying Modules by extremely

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.