pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
get attribute from XML
3+ messages / 2 participants
[nested] [flat]

* get attribute from XML
@ 2010-10-11 23:03  Viktor Bojović <viktor.bojovic@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Viktor Bojović @ 2010-10-11 23:03 UTC (permalink / raw)
  To: pgsql-sql

Hi,
while parsing this type of XML:
<entry version="21" modified="2009-07-07" dataset="S" created="2009-06-16">
<accession>Q91G55</accession>

i tried this query to get the modified attribute
select xpath('//entry/modified/text()',xml) from xml_sprot limit 10;
but it doesn't work.

So im asking if anyone can help me with that.

Thanx in advance
-- 
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: get attribute from XML
@ 2010-10-12 00:22  Markus Schatten <markus.schatten@foi.hr>
  parent: Viktor Bojović <viktor.bojovic@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Markus Schatten @ 2010-10-12 00:22 UTC (permalink / raw)
  To: pgsql-sql

Dear Viktor,

'modified' is an attribute node, so you need to use the @ sign to
acquire its value:

mschatte=# select xpath( '//entry/@modified', '<entry version="21"
modified="2009-07-07" dataset="S" created="2009-06-16" />' );
    xpath
--------------
 {2009-07-07}
(1 row)

HTH

M.S.

On Tue, Oct 12, 2010 at 1:03 AM, Viktor Bojović
<viktor.bojovic@gmail.com> wrote:
> Hi,
> while parsing this type of XML:
> <entry version="21" modified="2009-07-07" dataset="S" created="2009-06-16">
> <accession>Q91G55</accession>
>
> i tried this query to get the modified attribute
> select xpath('//entry/modified/text()',xml) from xml_sprot limit 10;
> but it doesn't work.
> So im asking if anyone can help me with that.
> Thanx in advance
> --
> ---------------------------------------
> Viktor Bojović
> ---------------------------------------
> Wherever I go, Murphy goes with me
>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: get attribute from XML
@ 2010-10-12 07:10  Viktor Bojović <viktor.bojovic@gmail.com>
  parent: Markus Schatten <markus.schatten@foi.hr>
  0 siblings, 0 replies; 3+ messages in thread

From: Viktor Bojović @ 2010-10-12 07:10 UTC (permalink / raw)
  To: Markus Schatten <markus.schatten@foi.hr>; +Cc: pgsql-sql

Dear Markus,
it works now. Thanx.

On Tue, Oct 12, 2010 at 2:22 AM, Markus Schatten <markus.schatten@foi.hr>wrote:

> Dear Viktor,
>
> 'modified' is an attribute node, so you need to use the @ sign to
> acquire its value:
>
> mschatte=# select xpath( '//entry/@modified', '<entry version="21"
> modified="2009-07-07" dataset="S" created="2009-06-16" />' );
>    xpath
> --------------
>  {2009-07-07}
> (1 row)
>
> HTH
>
> M.S.
>
> On Tue, Oct 12, 2010 at 1:03 AM, Viktor Bojović
> <viktor.bojovic@gmail.com> wrote:
> > Hi,
> > while parsing this type of XML:
> > <entry version="21" modified="2009-07-07" dataset="S"
> created="2009-06-16">
> > <accession>Q91G55</accession>
> >
> > i tried this query to get the modified attribute
> > select xpath('//entry/modified/text()',xml) from xml_sprot limit 10;
> > but it doesn't work.
> > So im asking if anyone can help me with that.
> > Thanx in advance
> > --
> > ---------------------------------------
> > Viktor Bojović
> > ---------------------------------------
> > Wherever I go, Murphy goes with me
> >
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
---------------------------------------
Viktor Bojović
---------------------------------------
Wherever I go, Murphy goes with me

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-10-12 07:10 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11 23:03 get attribute from XML Viktor Bojović <viktor.bojovic@gmail.com>
2010-10-12 00:22 ` Markus Schatten <markus.schatten@foi.hr>
2010-10-12 07:10   ` Viktor Bojović <viktor.bojovic@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox