Create XML elements from rows

From: Thangalin <thangalin(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Create XML elements from rows
Date: 2011-12-28 08:11:28
Message-ID: CAANrE7pFVUjr8ykAAVMHOvCA0UJPUzPoYwo+33un=W3KqOhehA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Data in a table called 'equipment_group' (eg) contains various equipment
categories:

bakeware
cookware
kitchenware
utensils

I would like to use these values as elements within an XML document.
Something like:

xmlelement( name eg.label )

Each of these data element can have multiple objects, as shown in the
following XML snippet:

<equipment>
<bakeware>
<object min-quantity="20">ramekin</object>
<object min-quantity="2" alias="pan">shallow baking pan</object>
</bakeware>
<cookware>
<object min-quantity="1" alias="pot">medium pot</object>
</cookware>
<utensils>
<object alias="torch">kitchen butane torch</object>
<object alias="sieve">fine-mesh sieve</object>
<object alias="whisk">wire whisk</object>
</utensils>
</equipment>

In PostgreSQL 9.1, I do not see an XML function that allows XML element
creation based on row data. It seems the row data is always used as the
values for elements.

How do you create XML elements using names stored as row data?

Thank you!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Marlowe 2011-12-28 08:15:17 Re: PostgreSQL 9.1 pg_dump setval() sets wrong value
Previous Message Raghavendra 2011-12-28 05:27:25 Re: Show <parameter> in psql does any calculations?