Re: get attribute from XML - Mailing list pgsql-sql

From Markus Schatten
Subject Re: get attribute from XML
Date
Msg-id AANLkTincUH=RzEuvzQ5BxE=_oDgWkWX9Vh8aVsHLL7L9@mail.gmail.com
Whole thread Raw
In response to get attribute from XML  (Viktor Bojović <viktor.bojovic@gmail.com>)
Responses Re: get attribute from XML  (Viktor Bojović <viktor.bojovic@gmail.com>)
List 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
>


pgsql-sql by date:

Previous
From: Viktor Bojović
Date:
Subject: get attribute from XML
Next
From: Andreas
Date:
Subject: Is there a conditional string-concatenation ?