It is probably best to store both the questions and answers in the same doc, and then break out the questions and answers using different filters. Here is an example approach:
<?xml version="1.0"?> <data> <question id="1"> <qtext>What does KB stand for?</qtext> <choices> <choice>Kilo Bits</choice> <choice>Key Board</choice> <choice>Kilo Bytes</choice> <choice>None</choice> </choices> <answer>2</answer> <answer>3</answer> </question> <question id="2"> <qtext>CPU stands for</qtext> <choices> <choice>Central Processing Unit</choice> <choice>Central Power Unit</choice> <choice>Core Processing Unit</choice> <choice>Core Power Unit</choice> </choices> <answer>1</answer> <answer>4</answer> </question> <question id="3"> <qtext>1 KB equals</qtext> <choices> <choice>1000 Bytes</choice> <choice>1024 Bytes</choice> <choice>1000 Bits</choice> <choice>1024 Bits</choice> <choice>Nothing</choice> </choices> <answer>2</answer> <answer>1</answer> </question> </data>
Then use any XML parser, XML::Parser, XML::Twig, etc. to extract the <choices> and <answer> parts separately. Yould could also probably do this using XSLT, too, if you wanted to reamin XML pure. But I would go for the perl-based solutions first.

-Mark


In reply to Re: XML templates + variables?? by kvale
in thread XML templates + variables?? by dagb

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.