【问题标题】:automated conversion Mysql Table into an XML-File - Preserve hierarchy自动将 Mysql 表转换为 XML 文件 - 保留层次结构
【发布时间】:2012-01-11 20:28:56
【问题描述】:

我想将表格中的行转换为 XML 层次结构。 mysql-table 的结构如下:

---table structure

CREATE TABLE IF NOT EXISTS `carrier_template_helper` (
  `carrier_id` int(5) NOT NULL DEFAULT '0',
  `tarifs_v` int(10) NOT NULL DEFAULT '0',
  `customer_f` varchar(30) NOT NULL,
  `templates_f` varchar(30) NOT NULL,
  `page` int(2) NOT NULL DEFAULT '1',
  `customer_f_contains_str` varchar(100) NOT NULL,

replace_strvarchar(100) 非空,add_str_beforevarchar(100) 非空,add_str_after varchar(100) 非空,call_method varchar(50) NOT NULL, font_size float NOT NULL DEFAULT '8',
add_xy varchar(10) NOT NULL DEFAULT '0:0', KEY carrier_id (carrier_id,tarifs_v,customer_f,templates_f) ) ENGINE=MyISAM 默认字符集=latin1;

INSERT INTO `carrier_template_helper` (`carrier_id`, `tarifs_v`, `customer_f`, `templates_f`, `page`, `customer_f_contains_str`, `replace_str`, `add_str_before`, `add_str_after`, `call_method`, `font_size`, `add_xy`) VALUES
(80, 2, 'billing_city', 'posbilling_city', 1, '', '', '', '', 'switch_to_city', 8, ''),
(80, 2, 'billing_street1', 'posbilling_street1', 1, '', '', '', '', 'switch_to_street1', 8, '');

(80, 11, 'billing_city', 'posbilling_city', 1, '', '', '', '', 'switch_to_city', 8, ''),
(80, 11, 'billing_street1', 'posbilling_street1', 1, '', '', '', '', 'switch_to_street1', 8, ''); '

我需要我的 XML 与carrier_id->tarifs_v 的层次结构,然后是其余的......在伪代码中是这样的

<?xml version="1.0"?>
<!DOCTYPE ...........>
<carriers>
<tarifs>
<customer_f>2</customer_f>
<tarifs_v>billing_city</tarifs_v>
<templates_f>posbilling_city</templates_f>
.
.
.
<tarifs>

<tarifs>
<customer_f>11</customer_f>
<tarifs_v>billing_city</tarifs_v>
<templates_f>posbilling_city</templates_f>
.
.
.
<tarifs>

</carriers>

我真的很想自动化...我使用什么工具最简单最好?

【问题讨论】:

    标签: mysql xml export


    【解决方案1】:

    我会使用带有 -X 选项的 mysql 控制台,它以 XML + XSLT 转换的形式返回结果。

    【讨论】:

      猜你喜欢
      • 2020-08-05
      • 2021-12-31
      • 1970-01-01
      • 2020-08-07
      • 1970-01-01
      • 2012-10-13
      • 1970-01-01
      • 2018-02-23
      • 1970-01-01
      相关资源
      最近更新 更多