Technically XML::Simple operates as a kind of (if not actually) a DOM parser (evidentally with some SAX or SAX-like options if you want those) -- but I agree with you. It's canon that parsing XML with regexes is a path to destruction.

Perhaps the OP has severe memory concerns (i.e. over bloated giant XML file)? If so, writing a SAX parser only to remove pieces of XML would be painful and DOM would not be a good choice. Yet line-oriented parsing isn't going to work with XML anyway, so you are slurping -- hence memory issues again. Yep, it would be best to pick one of the other (DOM-ish or SAX-ish), despite the tradeoffs. Maintaining Yet-Another-XML-Manipulator would be quite painful. If the file is small by machine standards, absolutely, XML::Simple is the easiest way to go. Do it, and you can still think mostly in Perl!


In reply to Re: Re: Regex et XML by flyingmoose
in thread Regex et XML by butlerdi

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.