Search Postgresql Archives

Re: Postgresql 8.4, XPath and name() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 13, 2010 at 4:03 AM, ced45 <cedric.duprez@xxxxxx> 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@xxxxxxxxxxxxxx/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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux