Thread: Export table/view in xml-format

Export table/view in xml-format

From
Detlef Jockheck
Date:
Hi,

is there a tool to export contents of a table or view in xml? I would like
something that:
--- cut ---
<xml-header>
    bla and blub
</xml-header>
<tablename>
    <row>
        <column_a>data</column_a>
        <column_b>data</column_b>.
        ...
    </row>
    <row>
        <column_a>data</column_a>
        <column_b>data</column_b>
        ...
    </row>
</tablename>
<xml-footer>
    some text
</xml-footer>
--- cut ---

ciao Detlef
--
# Dipl. Ing. (FH) Detlef Jockheck
# E-mail: detlef@jockheck.de
# -------------------------------

Re: Export table/view in xml-format

From
greg@turnstep.com
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> is there a tool to export contents of a table or view in xml? I would like
> something that:

There is some current discusion about having a switch in psql that would
enable this. I wrote a patch that does just this: see the link below.
Note that it was made against CVS tip (as of around 2 weeks ago) and will
probably not be identical to the final version. However, it should do what you asked for.

http://groups.google.com/groups?q=psql+XML&oe=UTF-8&selm=b9daa33f80cc0a0c73d984696cb8fbac%40biglumber.com


You can also look at the perl module DBIx:XML, which produces very similar results:

http://search.cpan.org/author/MSERGEANT/DBIx-XML_RDB-0.05/XML_RDB.pm


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200303100919
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+bKE2vJuQZxSWSsgRAsPIAJ9yZvGZoso4e5tf9fvxb/vUZXSqhgCcCKka
KhbIsi+5qz+KaFrtHEYEYOA=
=tI9M
-----END PGP SIGNATURE-----