tags:

views:

90

answers:

1

I have this XML file:

 <cjl>
    <job>
     <plan on="1">aa</plan>
     <exec>d.java</exec>
    </job>
 </cjl>

The job tag may be repeating and also the plan tag also may be repeating.

   <cjl>
    <job>
     <plan on="2">aa</plan>
    <exec>e.java</exec>
    </job>

    <job>
    <exec>f.java</exec>
     <plan on="1">bb</plan>
     <plan on="3">cc</plan>
    </job>
    </cjl>

In spite of whether it's single or array, I want to print the values as CSV. In the first case, I want to print:

d.java, aa, 1

The second XML file one should print the value in two lines as:

e.java, aa, 2
f.java, bb, cc, 1, 3

What is the best way to do that?

Also, since data are stored in XML files, how do I read them?

+2  A: 

XML::Simple is really supposed to be simple. Once you start doing anything other than reading or writing data structures, you need to move on to a fuller-featured XML tool. You might look at XML::Twig instead.

What have you tried so far?

brian d foy