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 1h5Th5-0003Vb-2E for pgsql-general@arkaria.postgresql.org; Sun, 17 Mar 2019 11:11:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h5Th3-000345-IB for pgsql-general@arkaria.postgresql.org; Sun, 17 Mar 2019 11:11:05 +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 1h5QM3-0005Xq-Hj for pgsql-general@lists.postgresql.org; Sun, 17 Mar 2019 07:37:11 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.122]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h5QM0-0003gj-M6 for pgsql-general@postgresql.org; Sun, 17 Mar 2019 07:37:10 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 1E724E77 for ; Sun, 17 Mar 2019 09:37:08 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aF40Iu4fk2kF for ; Sun, 17 Mar 2019 09:37:05 +0200 (EET) Received: from mail.hot.ee (hot-relayhost2.estpak.ee [213.180.2.80]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id B821869A for ; Sun, 17 Mar 2019 09:37:05 +0200 (EET) Received: from dell2 (66-63-196-88.sta.estpak.ee [88.196.63.66]) (Authenticated sender: kobruleht2) by HOT-Relayhost2.estpak.ee (Postfix) with ESMTPSA id 44MWNd4wbTzRk for ; Sun, 17 Mar 2019 09:37:04 +0200 (EET) Message-ID: From: "Andrus" To: "pgsql-general" Subject: How to parse XML in Postgres newer versions also Date: Sun, 17 Mar 2019 09:36:22 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="windows-1257"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal Importance: Normal X-Mailer: Microsoft Windows Live Mail 16.4.3528.331 X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi! In Postgres 9.1.2 script below produces proper results: 1.34 5.56 In Postgres 11 it produces wrong results: null null How to make it also to work in newer versions on Postgres ? create temp table t(x xml, nsa text[][]) on commit drop; insert into t values( ' 1.34 5.56 '::xml, ARRAY[ARRAY['ns','urn:iso:std:iso:20022:tech:xsd:camt.053.001.02']]); SELECT (xpath('Amt/text()', x,nsa))[1]::text::numeric AS tasusumma FROM ( SELECT unnest(xpath('/ns:Document/ns:BkToCstmrStmt/ns:Stmt/ns:Ntry', x,nsa)) as x, nsa FROM t ) Ntry Andrus.