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