From: | Ross Reedstrom <reedstrm(at)rice(dot)edu> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: help with xpath namespace |
Date: | 2011-11-08 22:59:37 |
Message-ID: | 20111108225937.GA9891@rice.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, Sep 26, 2011 at 09:56:06AM -0400, Brian Sherwood wrote:
> Yep, that did it.
>
> Thanks!
ProTip (for the list archive): since the namespace alias in the query and the
original XML don't need to match (in this common case, the document uses a
default namespace, which isn't available in xpaths), you can save significant
typing by using a single-character namespace:
select xpath(
'/j:chassis-inventory/j:chassis/j:serial-number/text()',
data_xml,
ARRAY[ARRAY['j',
'http://xml.juniper.net/junos/9.6R4/junos-chassis']]
)
from xml_test;
Ross
>
>
> 2011/9/23 Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>:
> >
> >
> > 2011/9/22 Brian Sherwood <bdsher(at)gmail(dot)com>
> >>
> >> select (xpath('/chassis-inventory/chassis/serial-number/text()',
> >> data_xml,
> >> ARRAY[ARRAY['junos',
> >> 'http://xml.juniper.net/junos/9.6R4/junos-chassis']]
> >> )) from xml_test;
> >>
> >> Can anyone suggest how I would go about getting the serial-number with
> >> xpath?
> >>
> >
> >
> > http://www.postgresql.org/docs/9.1/static/functions-xml.html#FUNCTIONS-XML-PROCESSING
> > - see "mydefns".
> >
> > This will work:
> >
> > select xpath(
> > '/junos:chassis-inventory/junos:chassis/junos:serial-number/text()',
> > data_xml,
> > ARRAY[ARRAY['junos',
> > 'http://xml.juniper.net/junos/9.6R4/junos-chassis']]
> > )
> > from xml_test;
> >
> >
> >
> > cheers, Filip
> >
> >
> >
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Kupershmidt | 2011-11-09 00:35:31 | Re: Partitionning + Trigger and Execute not working as expected |
Previous Message | David Johnston | 2011-11-08 21:45:59 | Re: Updatable view should truncate table fields |