News:
- In an internet driven environment, it is imperative for a company to keep its product or business to the forefront of potential customers' minds. The ...
- A successful enterprise is all about constantly reinventing ways to work more efficiently. In today’s techno age, this translates to testing new too...
- The IT industry plays a pivotal role in providing application development solutions and custom software development to a wide range of industries, i...
- Royal Victorian Eye and Ear Hospital, 2010 Atcomm has been contracted to implement a complex IOP glaucoma management tool which will be distribut...
- We are pleased to announce another implementation of a CMS system for a large Melbourne based fitness center - Star Plate Studio. Atcomm has depl...
-
font size
decrease font size
increase font size
1.25 Producing XML Output
1.25.1 Problem
You'd like to turn a query result into XML.
1.25.2 Solution
mysql can do that for you.
1.25.3 Discussion
mysql creates an XML document from the result of a query if you use the -X (or --xml) option. Here's an example that shows the difference between tabular format and the XML created from the same query:
% mysql -e "SELECT * FROM limbs WHERE legs=0" cookbook +------------+------+------+ | thing | legs | arms | +------------+------+------+ | squid | 0 | 10 | | octopus | 0 | 8 | | fish | 0 | 0 | | phonograph | 0 | 1 | +------------+------+------+ % mysql -X -e "SELECT * FROM limbs WHERE legs=0" cookbook|
squid 0 10 |
octopus 0 8 |
fish 0 0 |
phonograph 0 1
-X and --xml may be used as of MySQL 4.0. If your version of MySQL is older than that, you can write your own XML generator
Read 214 times
Published in
MySQL
Vicky
E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view itLatest from Vicky
More in this category:
« Turning Query Result to HTML output format using MySQL
Understanding the SSIS Interface 1 »