I guess I can take this as a suggestion that it would be worth it to implement this, right? :-)

You mean if the data look like this:

[ { 'lname' => 'Krynicky', 'fname' => 'Jenda', 'PageId' => 1, 'Details' => { Header => 'blah blah', Footer => 'bla bla bla', } }, ... ];
? You could use a template like this for example:
<root> <page cmd:foreach set:id="$_->{PageId}" opt:required> <field cmd:foreachkey="! /^(PageId|Details)$/"> <cmd:insert set:_tag="$key" set:_content="$value"/> </field> <details cmd:forkey="Details"> <cmd:insert cmd:foreachkey set:_tag="$key" set:_content="$value"/ +> </details> </page> </root>

That is you make sure the foreachkey in the <field> tag skips both the PageId and Details keys, include the <details> tag to present the values of the 'Details' key and finally foreachkey directly in the <cmd:insert> tag to print the data from the inner hash.

Is this what you meant? I assume writing the documentation for this will be quite hard. Just like the docs for XML::Rules were. And I don't think I did a perfect job there.


In reply to Re^2: Datastructures to XML by Jenda
in thread Datastructures to XML by Jenda

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.