From: | Steve Midgley <science(at)misuse(dot)org> |
---|---|
To: | ml(at)ft-c(dot)de |
Cc: | pgsql-sql(at)lists(dot)postgresql(dot)org |
Subject: | Re: xml build a list of all elements |
Date: | 2024-03-26 22:27:27 |
Message-ID: | CAJexoSLc5kimE1C83xjA9p_MLcvNyLs3Y1XjBe1M6mSpkBaoaQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Tue, Mar 26, 2024 at 2:05 PM ft <ml(at)ft-c(dot)de> wrote:
> Hello,
>
> I have a postgresql database table with xml data.
> What I need is a list of all elements and attributes.
> Example:
> <area>
> <sub>
> <sub2 attr='1'>comment</sub2>
> <sub2 attr='2'>comment</sub2>
> <sub>
> </area>
>
> The result should be:
> /area
> /area/sub
> /area/sub/sub2
> /area/sub/sub2(at)attr
> /area/sub/sub2
> /area/sub/sub2(at)attr
>
> or distinct (it's enough)
> /area
> /area/sub
> /area/sub/sub2
> /area/sub/sub2(at)attr
>
> Is there a postgresql function to build this list?
>
>
> I think it can be done but it'll be a painful function. I'd personally
recommend writing this in a higher level language that deals with xml as
rationally as it is possible to deal with xml (which is very unfriendly to
most programming languages). Possibly you could consider using a PL/Python
extension if you want processing to happen on the server, but I have no
idea about security/resource consumption implications of that approach. But
if you can get Python's lxml installed on your Pg server, having a library
like that would (for me) make this function a lot easier to write..
Steve
From | Date | Subject | |
---|---|---|---|
Next Message | James Cloos | 2024-04-01 22:03:26 | help with a particular multi-table query |
Previous Message | ft | 2024-03-26 21:04:55 | xml build a list of all elements |