I want to preface this by saying that I do not have a computer science degree, so I apologize if this question is boneheaded.

I am trying to build a very simple XML DTD parser in Perl. What I can't figure out, though, is if an element in the DTD is the parent element of another in that DTD (and so on and so forth) how I can follow them down for an indeterminate amount of levels.

For example. Lets say there is an element called < Particle > that was the parent of two elements called < Proton > and < Neutron > -- and they in turn were parents for elements < Top > , < Bottom > , < Charm > , and < Beauty > respectively. How can I create a hash with those elements as keys without knowing how many levels down the relationship goes?

I really hope this is making sense, because I feel that it shouldn't be that difficult. I could certainly figure it out if I knew that they were only going to go say 10 levels down, or a hundred, or some finite number, but I won't necessarily have that information.

Any guidance from the kinda and gentle monks here will be greatly appreciated.

jupe

Edit kudra, 2002-05-01 Changed title


In reply to How to build a simple XML DTD parser by jupe

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.