本文介绍了Postgres数据到XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道将数据库条目转换为XML的任何好方法吗?
Does anyone know any good methods for converting database entries into XML?
即如果我有一个名为 Users的表,其字段为 first_name, age, last_name,我想将该表转换为:
I.e. if i have a table named "Users" with fields "first_name", "age", "last_name", I'd like to convert the table to:
<Users> <first_name>Papa</first_name> <age>50</age> <last_name>John</last_name> </Users>推荐答案
在PostgreSQL中,您可以这样:
In PostgreSQL you could it like this:
SELECT table_to_xml('users', true, false, '');或
SELECT query_to_xml('SELECT * FROM users', true, false, '');还有其他选择,只需检查手册。
There are other options as well, just check the manual.
更多推荐
Postgres数据到XML
发布评论