https://dba.stackexchange.com/questions/155121/xml-parse-in-postgressql https://www.postgresql.org/docs/9.1/static/datatype-xml.html $PGDATA/my.xml 1 IT 1 2 3 4 5 hataevicha some descr do $$ declare xml_string xml; begin xml_string := XMLPARSE(DOCUMENT convert_from(pg_read_binary_file('my.xml'), 'UTF8')); drop table if exists my; create table my as select unnest(xpath('//data-set/department/id/text()',xml_string)) as ID, unnest(xpath('//data-set/department/id_customer/text()',xml_string)) as ID_CUSTOMER ; end$$; select * from my