<HTML dir=ltr><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3492" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face="Courier New" color=#000000 size=2>Somebody asked me for a demo like this&nbsp;(irc.perl.org #perl-help) today.</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2>j</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><FONT face="Courier New" size=2></FONT>&nbsp;</DIV>
<DIV><PRE>$ cat j.pl
#!/usr/bin/perl

use strict;
use XML::Twig;
my $twig = XML::Twig-&gt;new(
   pretty_print =&gt; 'indented'
)-&gt;parse('&lt;users/&gt;')-&gt;root;


my @users = (
  { firstname =&gt; 'Jay',
    lastname =&gt; 'Hannah'
  },
  { firstname =&gt; 'Quentus',
    lastname =&gt; 'Rex'
  },
);

foreach (@users) {
   my $elt = XML::Twig::Elt-&gt;new(
      user =&gt; {
         firstname =&gt; $_-&gt;{firstname},
         lastname  =&gt; $_-&gt;{lastname}
      }
   );
   $elt-&gt;paste( last_child =&gt; $twig );
}
print $twig-&gt;sprint;


$ perl j.pl
&lt;users&gt;
  &lt;user firstname="Jay" lastname="Hannah"/&gt;
  &lt;user firstname="Quentus" lastname="Rex"/&gt;
&lt;/users&gt;
</PRE>
<P></P>
<P></P>
<DIV align=right><FONT size=-1></FONT>&nbsp;</DIV>
<DIV align=right><FONT size=-1><A href="http://sf.net/projects/pastebot/"></A></FONT>&nbsp;</DIV></DIV></BODY></HTML>