MySQL Forums
Forum List  »  Connector/Node.js

Re: Does mySQL generate XML ?
Posted by: Geri
Date: October 10, 2006 08:33AM

Yes, the mysql cmd line tool generates XML output with option '--xml'.

Unfortunately the output format is:

<resultset statment="...">
<row>
<field name=".."> ...field contents... </field>
...more fields
<row>
...more rows
<resultset>

with a simple DTD like:

<!ELEMENT resultset (row)+>
<!ATTLIST resultset
statement CDATA #IMPLIED>
<!ELEMENT row (field)+>
<!ELEMENT field (#PCDATA)+>

From an abstract point of view the following would be better (with a table 'user', for instance):

<user>
<first_name>John</first_name>
<last_name>Doe</last_name>
<address>
<country>Austria</country>
<zip>2344</zip>
<city>Maria Enzersdorf</city>
</address>
</user>

With a more appealing DTD like (and even more appealing if this forum would know the <pre>-tag :-):

<!ELEMENT user (first_name, last_name, address)>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT last_name (#PCDATA)>
<!ELEMENT address (country, zip city)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
<!ELEMENT city (#PCDATA)>

This is how XML is meant to be used, as far as I understand it.

Geri

edit: corrected typos



Edited 2 time(s). Last edit at 10/10/2006 08:36AM by Geri .

Options: ReplyQuote


Subject
Written By
Posted
Re: Does mySQL generate XML ?
October 10, 2006 08:33AM
January 26, 2007 07:41AM
December 02, 2007 08:39PM
February 01, 2008 04:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.