MySQL获取XML格式数据

通过再调用mysql工具时使用--xml选项:

C:\Users\wang>mysql -uroot -p --xml mydb
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 5.7.21-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT * FROM favorite_food;
<?xml version="1.0"?>

<resultset statement="SELECT * FROM favorite_food;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <row>
        <field name="person_id">1</field>
        <field name="food">apple</field>
  </row>

  <row>
        <field name="person_id">1</field>
        <field name="food">banana</field>
  </row>

  <row>
        <field name="person_id">1</field>
        <field name="food">orange</field>
  </row>
</resultset>
3 rows in set (0.00 sec)
posted @ 2018-04-10 17:34  zifeiy  阅读(636)  评论(0编辑  收藏  举报