Thread: Need xml element constructor given tag, attribute array & children

Need xml element constructor given tag, attribute array & children

From
"J. Greg Davidson"
Date:
Hi Everybody,

I'm having trouble finding any way to build up
XML values from their logical components, e.g.
given an XML element tag, an array of attributes
in some form, and an xml[] array of children I
can't find any SQL function or expression which
would construct the XML element.  Surely the
syntactic sugary XMLPARSE must be calling such
a function?  Am I missing something or is
PostgreSQL missing something?

Thanks,

_Greg

Re: Need xml element constructor given tag, attribute array & children

From
Craig Ringer
Date:
On 29/06/10 09:49, J. Greg Davidson wrote:
> Hi Everybody,
>
> I'm having trouble finding any way to build up
> XML values from their logical components, e.g.
> given an XML element tag, an array of attributes
> in some form, and an xml[] array of children I
> can't find any SQL function or expression which
> would construct the XML element.  Surely the
> syntactic sugary XMLPARSE must be calling such
> a function?  Am I missing something or is
> PostgreSQL missing something?

The XMLELEMENT pseudo-function will do what you need.

http://www.postgresql.org/docs/current/static/functions-xml.html


--
Craig Ringer

Tech-related writing: http://soapyfrogs.blogspot.com/