I'm not sure there is a good enough general case there to warrant writing it. Most of the time once you get to SQL you are going to use more than one table. Factor in dependencies, one to many lookups and such and I don't know if there is a way to do that without it being specific to the data and application.

Now for individual tables and views on select you might be able to make some fancy inroads. You get back a table like:

keyfield  field1   field2
=========+========+==============
Data1     f1data   f2data
Data2     x1data   NULL

and you want out

<dbxml>
 <row>
  <col>
   <field>keyfield</field>
   <value>Data1</value>
  </col>
...

or would you expect

<dbxml>
 <row>
  <keyfield>Data1</keyfield>
  <field1>f1data</field1>
  <field2>f2data</field2>
 </row>
...

The first is pretty flexible since you don't have to deal with anything but a single DTD that describes the general layout. The second way you have to DTD every table so that your parser knows what to expect. And we haven't even dealt with CDATA yet or other madness. Basically, XML is super pimped up CSV in these cases. You use the power of XML to express the relationships between multiple tables and I can't even try to think about how it would be automatable so that you could pass it straight to SQL.

Thanks, now my brain hurts again. =)

--
$you = new YOU;
honk() if $you->love(perl)


In reply to Re: XML to DBI by extremely
in thread XML to DBI by markwild

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.