pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedGet attributes names
3+ messages / 2 participants
[nested] [flat]
* Get attributes names
@ 2019-01-24 08:54 ramsiddu007 <ramsiddu007@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: ramsiddu007 @ 2019-01-24 08:54 UTC (permalink / raw)
To: pgsql-general
Dear all,
I hope you are all doing well. Today i got one requirement,
for that i need attribute names as below example.
Xml:
<emp>
<emp_details emp_id="101" emp_name="tom" dept="development"/>
</emp>
In the above sample input xml, i want attributes list of emp_deails like.
Attributes
___________
emp_id
emp_name
dept
Thanking you,
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Get attributes names
@ 2019-01-24 09:54 Arthur Zakirov <a.zakirov@postgrespro.ru>
parent: ramsiddu007 <ramsiddu007@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Arthur Zakirov @ 2019-01-24 09:54 UTC (permalink / raw)
To: ramsiddu007 <ramsiddu007@gmail.com>; pgsql-general
On 24.01.2019 11:54, ramsiddu007 wrote:
> Dear all,
> I hope you are all doing well. Today i got one
> requirement, for that i need attribute names as below example.
>
> Xml:
> <emp>
> <emp_details emp_id="101" emp_name="tom" dept="development"/>
> </emp>
>
> In the above sample input xml, i want attributes list of emp_deails like.
> Attributes
> ___________
> emp_id
> emp_name
> dept
>
>
> Thanking you,
>
In PostgreSQL 11 (and 10 I think) you can do something like this:
=# CREATE TABLE xmldata AS SELECT xml $$
<emp>
<emp_details emp_id="101" emp_name="tom" dept="development"/>
</emp>
$$
as data;
=# SELECT xmltable.*
FROM xmldata,
xmltable('/emp/emp_details/@*' passing data
columns atrr text path 'name()');
atrr
----------
emp_id
emp_name
dept
--
Arthur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Get attributes names
@ 2019-01-24 10:03 ramsiddu007 <ramsiddu007@gmail.com>
parent: Arthur Zakirov <a.zakirov@postgrespro.ru>
0 siblings, 0 replies; 3+ messages in thread
From: ramsiddu007 @ 2019-01-24 10:03 UTC (permalink / raw)
To: Arthur Zakirov <a.zakirov@postgrespro.ru>; +Cc: pgsql-general
Hi Arthur,
Thanks for your help. But am using postgres 9.6 version.
On Thu, 24 Jan 2019, 15:24 Arthur Zakirov <a.zakirov@postgrespro.ru wrote:
> On 24.01.2019 11:54, ramsiddu007 wrote:
> > Dear all,
> > I hope you are all doing well. Today i got one
> > requirement, for that i need attribute names as below example.
> >
> > Xml:
> > <emp>
> > <emp_details emp_id="101" emp_name="tom" dept="development"/>
> > </emp>
> >
> > In the above sample input xml, i want attributes list of emp_deails like.
> > Attributes
> > ___________
> > emp_id
> > emp_name
> > dept
> >
> >
> > Thanking you,
> >
> In PostgreSQL 11 (and 10 I think) you can do something like this:
>
> =# CREATE TABLE xmldata AS SELECT xml $$
> <emp>
> <emp_details emp_id="101" emp_name="tom" dept="development"/>
> </emp>
> $$
> as data;
> =# SELECT xmltable.*
> FROM xmldata,
> xmltable('/emp/emp_details/@*' passing data
> columns atrr text path 'name()');
> atrr
> ----------
> emp_id
> emp_name
> dept
>
> --
> Arthur Zakirov
> Postgres Professional: http://www.postgrespro.com
> Russian Postgres Company
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-01-24 10:03 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 08:54 Get attributes names ramsiddu007 <ramsiddu007@gmail.com>
2019-01-24 09:54 ` Arthur Zakirov <a.zakirov@postgrespro.ru>
2019-01-24 10:03 ` ramsiddu007 <ramsiddu007@gmail.com>
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