From: | Thangalin <thangalin(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Create XML elements from rows |
Date: | 2011-12-28 12:46:57 |
Message-ID: | CAANrE7oxh=HaYyWUQzOa-mSLgZz6MgjmRwWgrr3c5SZKbfyTDA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Here is a partial solution to the problem I encountered (the full solution
uses a UNION ALL and the same statement four times):
SELECT
xmlelement( name "bakeware",
xmlconcat(
array_to_string( array_agg(
xmlelement( name "object",
xmlattributes( e.abridge AS "alias" ),
e.name
)
), '')::xml
)
)
FROM
recipe.equipment_group eg,
recipe.equipment e
WHERE
eg.label='bakeware' AND
eg.id = e.equipment_group_id
When all four instances are in place (bakeware, cookware, kitchenware,
utensils), this produces the following XML code:
<bakeware><object alias="pan">bread pan</object></bakeware>
<cookware/>
<kitchenware><object alias="">bowl (dry)</object><object alias="">bowl
(wet)</object></kitchenware>
<utensils/>
A simpler approach would require the following code to work:
xmlconcat( '<a>', '<b/>', '</a>' );
Unfortunately, the XML parser does not recognize that that series of
concatenations is well-formed XML.
Is there another approach that I am missing?
Thank you!
From | Date | Subject | |
---|---|---|---|
Next Message | hosuresh | 2011-12-28 12:56:54 | Re: psql error: psql: symbol lookup error: psql: undefined symbol: PQconnectdbParams |
Previous Message | John R Pierce | 2011-12-28 10:53:34 | Re: psql error: psql: symbol lookup error: psql: undefined symbol: PQconnectdbParams |