2012-01-11 11 views
0

私のテーブルの行をXML階層構造に変換したい。XMLファイルにMysqlテーブルを自動変換する - 階層を保存する

---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_str VARCHAR(100)NOT NULL、add_str_before VARCHAR(100) NOT NULL、add_str_after VARCHAR(100)NOT NULL、call_method VARCHAR(50)NOT:MySQLのテーブルは、このように構成されていますNULL、font_sizeフロートNOT NULL DEFAULT '8'、
add_xy VARCHAR(10)NOT NULL DEFAULT 0:0」、KEY carrier_idcarrier_idtarifs_vcustomer_ftemplates_f))ENGINE = MyISAMテーブル DEFAULT CHARSET = 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, ''); ' 

と私はcarrier_id-> tarifs_vし、その後、残りの階層であることを私のXMLを必要とする...擬似コードでこのような何か

<?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> 

私は本当にそれを自動化するのが大好きです。 ..どのツールを私は最も簡単で使いやすいですか?

答えて

0

-Xオプション付きのmysql consoleを使用して、結果をXML + XSLT変換として返します。

+0

ありがとうnewtover ....どのように私は必要な階層を認識するだろうか? – Confidence

関連する問題