I think it might be worth pointing out that the XML you provided is not realy a good layout. Perhaps you get it from somwhere else but I would consider it a main problem.

Since the order of elements in XML should not be a factor in there display, picture that code with the lines out of order and you'll see there is no relation (XML wise) between some of your attributes. This does not mean of course that you can't use that layout, just remember that it should be considered a modified subset of XML and that some Parsers may parse it correctly while others may not.

<default-id>0x654321</default-id> <default-id>0x123456</default-id> <attr-name>security_string</attr-name> <attr-name>model_name</attr-name> <alternate> <mtype>0x234567</mtype> <attr-id>0x654321</attr-id> </alternate> <alternate> <mtype></mtype> <attr-id></attr-id> </alternate>

You can see all the same data is there but now its lacking meaning, and that parses as the same XML as above. A solution might be to wrap each element inside another tag.

<attr name="model_name"> <alternate> <mtype>0x234567</mtype> <attr-id>0x654321</attr-id> </alternate> <default-id>0x654321</default-id> </attr> <attr name="security_string"> <alternate> <mtype></mtype> <attr-id></attr-id> </alternate> <default-id>0x123456</default-id> </attr>

___________
Eric Hodges

In reply to Re: Data structure advice needed by eric256
in thread Data structure advice needed by Anonymous Monk

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.