tags:

views:

21

answers:

1

I need to select a single row from MySql and get the results as well-formed XML, where the XML tags are the column names. Is there some built-in way to do this, or will I need to manually assemble the XML?

I want something like this:

< id >2< /id > < name >John Smith< /name > < age >34< /age >

Just to clarify and elaborate...

I am inside of a stored procedure in a MySql 5.1.5 database. The procedure needs to execute a simple query like:

SELECT ID, Name, Age FROM People WHERE ID = 5;

And I would like to get the results in XML that I can pass to a calling program.

Any built-in functionality to do this?

A: 

If you're using mysql from command line you can do this

mysql -uroot -e "SHOW VARIABLES LIKE '%version%'" --xml

See http://dev.mysql.com/tech-resources/articles/xml-in-mysql5.1-6.0.html

I'm not sure about within different programming languages or via libraries.

Noodles
I'm talking about from within a stored procedure.
Blackcoil