From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | pgsql(at)mohawksoft(dot)com |
Cc: | PostgreSQL <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: xpath not a good replacement for xpath_string |
Date: | 2009-07-28 20:00:55 |
Message-ID: | 4A6F58F7.3000007@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
pgsql(at)mohawksoft(dot)com wrote:
> Sorry to bring this up, I know you've been fighting about XML for a while.
>
> Currently, I am using XML2 functionality and have tried to get the newer
> XPath function to work similarly, but can't quite seem to do it.
>
> I think the current xpath function is too limited. (The docs said to post
> problems to hackers if I have an issue.)
>
> For instance, we have a web application that uses java with an XML class
> serializer/deserializer Xstream. It creates XML that looks like this:
>
> <com.company.local.myclass>
> <uuid>b5212259-a91f-4dca-a547-4fe89cf2f32c</uuid>
> <email>joe(at)somedomain(dot)com</email>
> </com.company.local.myclass>
>
> My current strategy is to use xml2 as:
>
> select xpath_string(datum, E'/com\.company\.local\.myclass/uuid) as uuid
> from table;
>
> Which produces a usable:
> b5212259-a91f-4dca-a547-4fe89cf2f32c
>
> I have been trying to use xpath
> select xpath(E'/com\.company\.local\.myclass/uuid', XMLPARSE(CONTENT
> datum)) as uuid from table;
>
> Which produces an unusable:
> {<uuid>b5212259-a91f-4dca-a547-4fe89cf2f32c</uuid>}
>
>
>
>
This is really a usage question, which doesn't belong on -hackers.
However, here is how to do what you want:
andrew=# select
(xpath($$/com.company.local.myclass/uuid/text()$$,$$<com.company.local.myclass>
<uuid>b5212259-a91f-4dca-a547-4fe89cf2f32c</uuid>
<email>joe(at)somedomain(dot)com</email>
</com.company.local.myclass>
$$::xml))[1]::text as uuid;
uuid
--------------------------------------
b5212259-a91f-4dca-a547-4fe89cf2f32c
(1 row)
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2009-07-28 20:06:48 | Re: xpath not a good replacement for xpath_string |
Previous Message | Mike Rylander | 2009-07-28 20:00:10 | Re: xpath not a good replacement for xpath_string |