example for xmltable with XMLNAMESPACES

Started by Arjen Nienhuisalmost 9 years ago2 messages
#1Arjen Nienhuis
a.g.nienhuis@gmail.com

It wasn't completely clear for me how to use namespaces in xmltable().
Maybe add this to the documentation. It shows the default namespace
and quoting the namespace name.

WITH xmldata(data) AS (VALUES ('
<example xmlns="http://example.com/myns&quot; xmlns:B="http://example.com/b&quot;&gt;
<item foo="1" B:bar="2"/>
<item foo="3" B:bar="4"/>
<item foo="4" B:bar="5"/>
</example>'::xml)
)
SELECT xmltable.*
FROM XMLTABLE(XMLNAMESPACES('http://example.com/myns&#39; AS x,
'http://example.com/b&#39; AS "B"),
'/x:example/x:item'
PASSING (SELECT data FROM xmldata)
COLUMNS foo int PATH '@foo',
bar int PATH '@B:bar');
foo | bar
-----+-----
1 | 2
3 | 4
4 | 5
(3 rows)

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Arjen Nienhuis (#1)
Re: example for xmltable with XMLNAMESPACES

Arjen Nienhuis wrote:

It wasn't completely clear for me how to use namespaces in xmltable().
Maybe add this to the documentation. It shows the default namespace
and quoting the namespace name.

Thanks, pushed.

--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers