From: | ramsiddu007 <ramsiddu007(at)gmail(dot)com> |
---|---|
To: | Arthur Zakirov <a(dot)zakirov(at)postgrespro(dot)ru> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Get attributes names |
Date: | 2019-01-24 10:03:37 |
Message-ID: | CA+zEy78FpHKXPk2Xj_ZOMmvBspiUi3E_VnaFRN6ig+L1y3L1vg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(dot)zakirov(at)postgrespro(dot)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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Ron | 2019-01-24 10:11:29 | [pgbackrest] Expiring the last backup? |
Previous Message | Ron | 2019-01-24 10:01:06 | Re: Need a command to take the backup of the child tables along with its master table. |