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

xml to database?

by csuhockey3 (Curate)
on Aug 06, 2003 at 18:08 UTC ( [id://281533]=perlquestion: print w/replies, xml ) Need Help??

csuhockey3 has asked for the wisdom of the Perl Monks concerning the following question:

Hey monks,

I have a series of XML emails that I need to parse and throw into a mysql databse. Anyone know of mods. to help with this? I have found SQL -> XML on CPAN, I need the opposite.

Thanks!

Replies are listed 'Best First'.
Re: xml to database?
by mpeppler (Vicar) on Aug 06, 2003 at 18:25 UTC
    I use XML::XQL to extract data from XML blocks. I haven't really needed to build anything really generic yet, so my use so far has been very ad-hoc, grabbing pre-defined parts of the XML block and storing this in the database.

    But XML::XQL (and friends) should be a good starting point for you.

    Michael

      Thanks -- just what I needed to get going the right direction! New to perl, much appreciation.

        I wouldn't use XML::XQL though. It is a rather old module, but most of all it is based on a query language that never became a standard. There is really no point in learning XQL nowadays. You would be much better of learning XPath, either using XML::XPath or (probably a better idea) XML::LibXML.

Re: xml to database?
by mirod (Canon) on Aug 06, 2003 at 20:01 UTC

    The reason you have seen SQL to XML on CPAN is because it is quite easy to define an XML structure that will hold the result of an SQL query. Relational tables have a well defined structure, and the XML just mirrors it. So you can take any SQL query and dump it as XML using a DTD defined by the module.

    Now doing the opposite is quite different. You have to take an XML document with an unknown structure, and map it to one, or more, row, or maybe table. There is no hard and fast rule here.

    So you will have to write code for this.

    Hopefully the code is not necessarily very complex. Look at Ways to Rome 2 - Kourallinen Dollareita for examples of how to do a very similar task, using various modules.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://281533]
Approved by mpeppler
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found