If you are doing this as a learning exercise then you should take a look at the code used in some of the XML modules in CPAN. Note that many of the XML:: modules sit on top of one of a small number of parser modules, so bearing that in mind you might start by looking at something like XML::Parser.

The next next level up are modules like XML::TreeBuilder which maps fairly closely to what you have described so far. Beyond that are modules like XML::Twig which add ways of manipulating XML as it is being parsed thus reducing the need to store large parts of the file being processed in memory.

A common theme with these modules is that they are object oriented and tend to represent interesting parts of the XML document as objects. XML documents tend to have a highly recursive structure and using OO is one good way of dealing with that.

If, on the other hand you simply need a better way of dealing with XML than using XML::Simple (which is not), then you would save about ten years of your life by using XML::Twig or one of the other CPAN XML munging offerings.

True laziness is hard work

In reply to Re: Programmatic access of hashes by GrandFather
in thread Programmatic access of hashes by rthawkcom

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.