Skip site navigation (1) Skip section navigation (2)

XML2 module and xpath_table

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$ (view raw, whole thread or download thread mbox)
Lists: pgsql-general

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

Now according to
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:

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

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


pgsql-general by date

Next:From: Maarten DeprezDate: 2008-05-21 11:33:02
Subject: Re: escaping and quoting
Previous:From: GordonDate: 2008-05-21 08:34:34
Subject: Re: Results of stored procedures in WHERE clause

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group