Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmbiZ-0002lt-8d for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 09:54:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmbiX-0006w5-HC for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 09:54:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmbiX-0006vy-4q for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 09:54:37 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmbiU-0000i6-1u for pgsql-general@postgresql.org; Thu, 24 Jan 2019 09:54:36 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id CCE0221DE12E; Thu, 24 Jan 2019 12:54:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.237] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id A48C821DE12A; Thu, 24 Jan 2019 12:54:32 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1548323672; bh=SCOvPRpQ1iepjiyMj632vB+EAHjvPVSDpNr7+PCaUv4=; h=Subject:To:References:From:Date:In-Reply-To; b=DXb61j4gXUyMWblTCuXvpBKjzWZxdHFKaHGQYKd1WVCNraBwD9oMzzKLjm7+SQHGE 8MFPY+zUcY3hhCICd4Cw0Smxtblv3Bn0wW/b4a7TVOpK+5pMTgoNNQ4m+mYABowW/e aIcMgc2Oq6qON53DYaVW3F6d5ji54f+f0/a3rAx8= Subject: Re: Get attributes names To: ramsiddu007 , pgsql-general@postgresql.org References: From: Arthur Zakirov Message-ID: Date: Thu, 24 Jan 2019 12:54:32 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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: > > > > > 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 $$ $$ 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