Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-19 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found