Re: xml - Mailing list pgsql-general

From Pavel Stehule
Subject Re: xml
Date
Msg-id CAFj8pRA8zVpoLtwVe2SaOEOnbOhbRTXCqN70GKjfMHmc3htpaA@mail.gmail.com
Whole thread Raw
In response to xml  ("gary.wolfe" <gary.wolfe@biosourcetechnologies.com>)
Responses Re: xml  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general


2015-03-23 12:40 GMT+01:00 Ramesh T <rameshparnanditech@gmail.com>:
Hi all,
             SELECT  xmlagg(xmlelement(
                          name actor, xmlattributes(first_name)
                        )ORDER BY actor_id,',')from actor;

the above code return following result,

Inline image 1
Question :

i want retrieve  result from above XML result like
penelope,nick,jennifer,jhony,,,,,


result of xmlagg is not valid xml.

if you use xmlelement, then you can get valid xml

ostgres=# select * from x;
                               a                              
---------------------------------------------------------------
 <d><actor first_name="Pavel"/><actor first_name="Tomas"/></d>
(1 row)

postgres=# select unnest(xpath('//actor/@first_name',a)::text[]) from x;
 unnest
--------
 Pavel
 Tomas
(2 rows)

Regards

Pavel
 

xpath is their but unable to fix  this query.

any help how to get only names from query not xml.



Attachment

pgsql-general by date:

Previous
From: Pujol Mathieu
Date:
Subject: Re: COPY command file name encoding issue (UTF8/WIN1252)
Next
From: Scott Ribe
Date:
Subject: scope quirk in copy in function