Re: Using xpath queries against XML Datatype

Поиск
Список
Период
Сортировка
От Tim Landscheidt
Тема Re: Using xpath queries against XML Datatype
Дата
Msg-id m36363d8h2.fsf@passepartout.tim-landscheidt.de
обсуждение исходный текст
Ответ на Using xpath queries against XML Datatype  ("Balma Robin Gordon" <RGBALMA@qinetiq.com>)
Список pgsql-novice
"Balma Robin Gordon" <RGBALMA@qinetiq.com> wrote:

> [...]
> How do I do this in PostgreSQL?  I'm struggling trying to find any
> documentation/examples.  The following does not appear to return
> anything, but I'm not sure if I have the syntax quite right:

> select * from sensorML WHERE (xpath('//sml:System/@gml:id',
> "sensorML_xml",
> ARRAY[ARRAY['sml','http://www.opengis.net/sensorML/1.0.1'],ARRAY['gml','
> http://www.opengis.net/sensorML/1.0.1']]))::text

> = 'CTD1454';

xpath () returns an /array/ of XML values; so you have to
either compare the result to an array or just compare the
first element:

| SELECT * FROM sensorML WHERE ((xpath('//sml:System/@gml:id',
|                                      sensorML_xml,
|                                      ARRAY [ARRAY ['sml', 'http://www.opengis.net/sensorML/1.0.1'],
|                                             ARRAY ['gml', 'http://www.opengis.net/gml']])) [1])::TEXT = 'CTD1454';

Tim

В списке pgsql-novice по дате отправления:

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: Novice PL/pgSQL question and example
Следующее
От: u235sentinel
Дата:
Сообщение: Re: Postgres Triggers issue