Sample Header Ad - 728x90

xml parse in postgresSQL

4 votes
1 answer
11647 views
I have a problem with parse simple xml: 1 IT 1 2 3 4 5 Pražská platba kartou This XML file I parsed with use code: DO $$ DECLARE myxml xml; BEGIN myxml := XMLPARSE(DOCUMENT convert_from(pg_read_binary_file('MyData.xml'), 'UTF8')); DROP TABLE IF EXISTS my; CREATE TABLE my AS SELECT (xpath('//ID', x))::text AS ID, (xpath('data-set/@Name', x))::text AS Name, (xpath('//ID_CUSTOMER', x))::text AS id_customer, (xpath('//Adress', x))::text AS Adress, (xpath('//Desc', x))::text AS tgen FROM unnest(xpath('//data-set', myxml)) x ; END$$; select * from my Unfortunately, this parse gives me only first single row in result. I need create table where are all record in to relevant rows: Rows1 - ID 1, ID_CUSTOMER 1, Adress Pražská, Desc Platba kartou Rows2 - ID 1, ID_CUSTOMER 2, Adress Pražská, Desc Platba kartou Rows3 - ID 1, ID_CUSTOMER 3, Adress Pražský, Desc Platba kartou Rows4 - ........ Rows5 - ........ Thank you for your tips.
Asked by michal (103 rep)
Nov 13, 2016, 09:51 AM
Last activity: Jan 19, 2021, 02:04 PM