Re: How to parse XML in Postgres newer versions also

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to parse XML in Postgres newer versions also
Date: 2019-03-17 14:11:44
Message-ID: E5C5B1781F2B4A2787DF9D68C603F0E8@dell2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

>This variant is working
>postgres=# SELECT
> (xpath('/ns:Ntry/ns: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
>;

>But I have not a idea, why old code doesn't work. It is little bit strange so it worked without namespace before Amt tag.

In 9.1.5 it returns nulls

In 9.1.5 without namespaces

(xpath('Amt/text()', x,nsa))[1]::text::numeric AS tasusumma

works.

How to make it work in both versions?
Is it possible add some CASE WHEN or IF command or any other idea ?

Andrus.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2019-03-17 14:12:56 Re: How to parse XML in Postgres newer versions also
Previous Message Pavel Stehule 2019-03-17 14:05:34 Re: How to parse XML in Postgres newer versions also