Re: Postgresql 8.4, XPath and name() function - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Postgresql 8.4, XPath and name() function
Date
Msg-id AANLkTiktGlmIivdLyYltUwPjMquz7VLgwKoovviBNR2o@mail.gmail.com
Whole thread Raw
In response to Postgresql 8.4, XPath and name() function  (ced45 <cedric.duprez@ifn.fr>)
List pgsql-general
On Tue, Jul 13, 2010 at 4:03 AM, ced45 <cedric.duprez@ifn.fr> wrote:
>
> Hi List,
>
> I have trouble using XPath name() function in a XML field.
> For example, when I execute the following query :
>
> SELECT XPATH('name(/*)', XMLPARSE(DOCUMENT '<unit>value</unit>'))
>
> I would like to get "unit", but I just get an empty array ({}).
> How can I get "unit" ?

postgres is slightly broken in this regard.  here is some discussions
and a (might not work anymore) patch to fix the behavior if you're
feeling adventurous...

http://www.mail-archive.com/pgsql-hackers@postgresql.org/msg143339.html

here is a 'works for my cases but probably not all of yours' regex
solution that I use sometimes:
create or replace function xnode(_xml xml) returns text as
$$
  select substring($1::text from '^<([[:alnum:]]+).*>');
$$ language sql immutable;

merlin

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: Database recovery after dropdb
Next
From: Darin Del Vecchio
Date:
Subject: Any ideas on Version 9.0 production release date?