Re: Postgresql 8.4, XPath and name() function

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Postgresql 8.4, XPath and name() function
Дата
Msg-id AANLkTiktGlmIivdLyYltUwPjMquz7VLgwKoovviBNR2o@mail.gmail.com
обсуждение исходный текст
Ответ на Postgresql 8.4, XPath and name() function  (ced45 <cedric.duprez@ifn.fr>)
Список 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 по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Database recovery after dropdb
Следующее
От: Darin Del Vecchio
Дата:
Сообщение: Any ideas on Version 9.0 production release date?