public inbox for [email protected]  
help / color / mirror / Atom feed
From: Steve Midgley <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: Re: xml build a list of all elements
Date: Tue, 26 Mar 2024 15:27:27 -0700
Message-ID: <CAJexoSLc5kimE1C83xjA9p_MLcvNyLs3Y1XjBe1M6mSpkBaoaQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On Tue, Mar 26, 2024 at 2:05 PM ft <[email protected]> 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@attr
> /area/sub/sub2
> /area/sub/sub2@attr
>
> or distinct (it's enough)
> /area
> /area/sub
> /area/sub/sub2
> /area/sub/sub2@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


view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: xml build a list of all elements
  In-Reply-To: <CAJexoSLc5kimE1C83xjA9p_MLcvNyLs3Y1XjBe1M6mSpkBaoaQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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