pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSelecting data from XML
2+ messages / 2 participants
[nested] [flat]
* Selecting data from XML
@ 2012-07-16 19:56 Victor Sterpu <victor@caido.ro>
0 siblings, 1 reply; 2+ messages in thread
From: Victor Sterpu @ 2012-07-16 19:56 UTC (permalink / raw)
To: pgsql-sql
If I have a XML like this
<?xml version="1.0" encoding="UTF-8"?>
<Errors>
<Error code="CLIN102" validFrom="1980-02-23"/>
<Error code="CLIN103" validFrom="1980-02-23" validTo="2012-01-01"/>
</Errors>
can I write a query that will output the columns names and values like this?
code;validFrom;validTo
------------------------------
CLIN102;1980-02-23;
CLIN103;1980-02-23;2012-01-01
Thank you
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Selecting data from XML
@ 2012-07-17 03:23 Craig Ringer <ringerc@ringerc.id.au>
parent: Victor Sterpu <victor@caido.ro>
0 siblings, 0 replies; 2+ messages in thread
From: Craig Ringer @ 2012-07-17 03:23 UTC (permalink / raw)
To: Victor Sterpu <victor@caido.ro>; +Cc: pgsql-sql
On 07/17/2012 03:56 AM, Victor Sterpu wrote:
> If I have a XML like this
> <?xml version="1.0" encoding="UTF-8"?>
> <Errors>
> <Error code="CLIN102" validFrom="1980-02-23"/>
> <Error code="CLIN103" validFrom="1980-02-23" validTo="2012-01-01"/>
> </Errors>
>
> can I write a query that will output the columns names and values like this?
>
> code;validFrom;validTo
> ------------------------------
> CLIN102;1980-02-23;
> CLIN103;1980-02-23;2012-01-01
http://www.postgresql.org/docs/9.1/static/functions-xml.html#FUNCTIONS-XML-PROCESSING
You should be able to do it with some xpath expressions. It probably
won't be fast or pretty. Consider using PL/Python, PL/perl, PL/Java, or
something like that to do the processing and return the resultset.
--
Craig Ringer
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2012-07-17 03:23 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-07-16 19:56 Selecting data from XML Victor Sterpu <victor@caido.ro>
2012-07-17 03:23 ` Craig Ringer <ringerc@ringerc.id.au>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox