pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrus <kobruleht2@hot.ee>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to parse XML in Postgres newer versions also
Date: Sun, 17 Mar 2019 16:11:44 +0200
Message-ID: <E5C5B1781F2B4A2787DF9D68C603F0E8@dell2> (raw)
In-Reply-To: <CAFj8pRCZyo7BZwweHR236SnTvLCgf9UjEtKOsVwGeNBtPd3mBw@mail.gmail.com>
References: <DDC50001C3E84A67934B664BA564AF61@dell2>
	<CAFj8pRCZyo7BZwweHR236SnTvLCgf9UjEtKOsVwGeNBtPd3mBw@mail.gmail.com>

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.

view thread (9+ messages)  latest in thread

Message-ID: <E5C5B1781F2B4A2787DF9D68C603F0E8@dell2>
Permalink:  ../E5C5B1781F2B4A2787DF9D68C603F0E8@dell2/
Also on:    postgresql.org/message-id/E5C5B1781F2B4A2787DF9D68C603F0E8@dell2

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: kobruleht2@hot.ee, pavel.stehule@gmail.com
  Subject: Re: How to parse XML in Postgres newer versions also
  In-Reply-To: <E5C5B1781F2B4A2787DF9D68C603F0E8@dell2>
  References: <DDC50001C3E84A67934B664BA564AF61@dell2> <CAFj8pRCZyo7BZwweHR236SnTvLCgf9UjEtKOsVwGeNBtPd3mBw@mail.gmail.com> <E5C5B1781F2B4A2787DF9D68C603F0E8@dell2>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox