Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

How to format this xml output?

by sen (Hermit)
on Jan 23, 2006 at 11:28 UTC ( #524897=perlquestion: print w/replies, xml ) Need Help??
sen has asked for the wisdom of the Perl Monks concerning the following question:


I am new to perl. I tried lot. I have some xml file. I have to parse the xml file and insert the fields into database. I use XML::Simple to parse the data. It's working fine. I am getting output like this

one => 1, two => [ { x => 1, y => [ { a => 1, b => 2 }, { a => 2, b => 3} ] } ]

But, I need to insert into my database like this below. Please give me some ideas.
one => 1, two => [ { x => 1, y_a => 1, y_b => 2, }, { x => 1, y_a => 2, y_b => 3 } ]

Replies are listed 'Best First'.
Re: How to format this xml output?
by glasswalk3r (Friar) on Jan 23, 2006 at 12:20 UTC

    It would be better if you provide a sample of your XML and the database table that you want to insert data. In both cases, this has nothing to do with format XML output (I thought it was something related to XSL).

    Once you have the data in array ref, you just need to extract the data that you want dereferencing it. Looks like the XML file that you have doesn't have the same structure of the database table, so you will need to do some data transformation.

    Take a good look at the perldoc perlref document to see how to do that.

    Alceu Rodrigues de Freitas Junior
    "You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill
Re: How to format this xml output?
by planetscape (Chancellor) on Jan 24, 2006 at 06:58 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://524897]
Approved by gube
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2017-11-19 14:27 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (281 votes). Check out past polls.