Not an answer, but in all the answer examples given the XML source is not proper XML (at least for this purpose). Sure there are 'email' tags and there are 'name' tags but there's no 'email/name' container gluing the two together. At best you can only guarantee that the sample can be parsed into an array of emails and an array of names, but making assumptions that there is an association between the email and name is eventually going to bite you.

Here's a 'functionally' equivalent source sample:
my $_='<xml> <email>toto@foo.com</email> <email>tata@bar.com</email> <email>tutu@baz.com</email> <name>Toto</name> <name>Tata</name> <name>Tutu</name> </xml>';
And so is this:
my $_='<xml> <email>tata@bar.com</email> <email>toto@foo.com</email> <name>Tutu</name> <email>tutu@baz.com</email> <name>Toto</name> <name>Tata</name> </xml>';

The examples above are both valid representations of the original source sample and I'm pretty sure XML parsers are within their design rights to re-organize the data as they see fit.

A better source for example answer code would be this:
my $_='<xml> <user><email>toto@foo.com</email><name>Toto</name></user> <user><email>tata@bar.com</email><name>Tata</name></user> <user><email>tutu@baz.com</email><name>Tutu</name></user> </xml>';

Originally posted as a Categorized Answer.


In reply to Re: Strip that XML! by ruzam
in thread Strip that XML! by redbeard

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.