Skip site navigation (1) Skip section navigation (2)

Re: Using xpath queries against XML Datatype

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Using xpath queries against XML Datatype
Date: 2010-02-11 16:48:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
"Balma Robin Gordon" <RGBALMA(at)qinetiq(dot)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',''],ARRAY['gml','

> = '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', ''],
|                                             ARRAY ['gml', '']])) [1])::TEXT = 'CTD1454';


In response to

pgsql-novice by date

Next:From: u235sentinelDate: 2010-02-11 19:36:26
Subject: Re: Postgres Triggers issue
Previous:From: Jasen BettsDate: 2010-02-11 11:31:04
Subject: Re: Novice PL/pgSQL question and example

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group