Database Reference
In-Depth Information
An XML value can be produced in a couple of ways including the SQL standard
method.
XMLPARSE ( { DOCUMENT | CONTENT } value)
PostgreSQL also has a specific syntax that will also produce an XML value.
xml '<foo>bar</foo>'
'<foo>bar</foo>'::xml
An XML value can be easily converted to a text representation by using the
XMLSERIALIZE function.
XMLSERIALIZE ( { DOCUMENT | CONTENT } value AS
type )
Additionally, PostgreSQL allows you to simply cast the XML value as text.
Note
The full description of the XML data type and it's associated functions is at
http://www.postgresql.org/docs/current/static/datatype-xml.html . As each version
of PostgreSQL has improved, the support for XML has also improved.
There are several *_to_xml functions in PostgreSQL, which take as input either a
SQL query or a table or view and return its corresponding XML representation.
Let's look at this using the fiverows table we defined previously in the cursors sec-
tion.
First, let's get the table data as XML:
hannu=# select table_to_xml('fiverows',true,
false, '') as s;
Search WWH ::




Custom Search