XML2 module and xpath_table

Lists: pgsql-general
From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: XML2 module and xpath_table
Date: 2008-05-21 10:05:47
Message-ID: g10s5r$o3q$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi,

I am using xpath_table to convert elements from an XML column to "rows".

Now according to
http://www.postgresql.org/docs/8.3/static/xml2.html
this function will be removed in a future version.

That chapter also claims that the new XML syntax covers the functionality of the xml2 module, but I cannot find a way to return the elements of an XML document as rows (as xpath_table does)

Suppose I have the following content in my xml column:

<team>
<member id="10" name="Arthur Dent"/>
<member id="11" name="Ford Prefect"/>
</team>

I am using a statement similar to this:

select member_id, member_name
from xpath_table('id', 'xml_text', 'xmltest', '/team/member/@id|/team/member/@name', 'true')
as t(id integer, member_id varchar, member_name varchar)

to get the following output

member_id member_name
10 Arthur Dent
11 Ford Prefect

How would I achieve the same without using the deprecated xml2 module?

Thanks in advance
Thomas


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Subject: Re: XML2 module and xpath_table
Date: 2008-05-24 11:35:27
Message-ID: 200805241335.27917.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Am Mittwoch, 21. Mai 2008 schrieb Thomas Kellerer:
> How would I achieve the same without using the deprecated xml2 module?

xpath_table is probably the major piece that is not directly covered by the
new system. So until we have a replacement, we probably won't remove the old
module.


From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: XML2 module and xpath_table
Date: 2008-05-24 14:58:18
Message-ID: g19aea$9dd$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Peter Eisentraut wrote on 24.05.2008 13:35:
> Am Mittwoch, 21. Mai 2008 schrieb Thomas Kellerer:
>> How would I achieve the same without using the deprecated xml2 module?
>
> xpath_table is probably the major piece that is not directly covered by the
> new system. So until we have a replacement, we probably won't remove the old
> module.
>
Ah, good to know.

Thanks for the answer