xml档转成文字档
请教各位大大....小弟使用WebClient.DownloadString Method 将一个xml档转成文字档code如下:
WebClient client = new WebClient(); string reply = client.DownloadString("http://xxxxxx");
将得到的reply 写成123.txt档
原本的xml档如下:
程序代码:
<?xml version="1.0" encoding="big5" ?> - <Book> <execute_result>success</execute_result> - <data_item> <Publishers>A-list</Publishers> <name>AAA</name> <MarketJMark>N</MarketJMark> - <cond_list> - <cond> <name>con1</name> <value>2</value> </cond> - <cond> <name>con2</name> <value>1</value> </cond> - <cond> <name>con3</name> <value>4</value> </cond> </cond_list> - <commodity_list> - <commodity_data> <commodity>A-e</commodity> <name>A-c</name> <kind>F</kind> <point_num>1</point_num> <JMark>N</JMark> - <month_list> <month>201112</month> <month>201201</month> <month>201202</month> </month_list> </commodity_data> - <commodity_data> <commodity>AA-e</commodity> <name>AA-c</name> <kind>F</kind> <point_num>3</point_num> <JMark>N</JMark> - <month_list> <month>201112</month> <month>201203</month> <month>201205</month> <month>201207</month> <month>201209</month> <month>201212</month> </month_list> </commodity_data> </commodity_list> </data_item> - <data_item> <Publishers>B-list</Publishers> <name>BBB</name> <MarketJMark>N</MarketJMark> - <cond_list> - <cond> <name>con1</name> <value>2</value> </cond> - <cond> <name>con2</name> <value>1</value> </cond> - <cond> <name>con3</name> <value>4</value> </cond> - <cond> <name>con4</name> <value>8</value> </cond> </cond_list> - <commodity_list> - <commodity_data> <commodity>B-e</commodity> <name>B-c</name> <kind>F</kind> <point_num>4</point_num> <JMark>N</JMark> - <month_list> <month>201112</month> <month>201203</month> <month>201206</month> <month>201209</month> </month_list> </commodity_data> - <commodity_data> <commodity>BB-e</commodity> <name>BB-c</name> <kind>F</kind> <point_num>2</point_num> <JMark>N</JMark> - <month_list> <month>201112</month> <month>201201</month> <month>201203</month> <month>201205</month> <month>201207</month> <month>201208</month> </month_list> </commodity_data> </commodity_list> </data_item> - <data_item> <Publishers>C-list</Publishers> <name>CCC</name> <MarketJMark>N</MarketJMark> - <cond_list> - <cond> <name>con1</name> <value>2</value> </cond> - <cond> <name>con2</name> <value>1</value> </cond> - <cond> <name>con3</name> <value>4</value> </cond> </cond_list> - <commodity_list> - <commodity_data> <commodity>C-e</commodity> <name>C-c</name> <kind>F</kind> <point_num>1</point_num> <JMark>N</JMark> - <month_list> <month>201112</month> <month>201203</month> <month>201206</month> <month>201209</month> </month_list> </commodity_data> </commodity_list> </data_item> </Book>
转成123.txt档后变这样:
<?xml version="1.0" encoding="big5" ?><Book><execute_result>success</execute_result><data_item><Publishers>A-list</Publishers><name>AAA</name><MarketJMark>N</MarketJMark><cond_list><cond><name>con1</name><value>2</value></cond><cond><name>con2</name><value>1</value></cond><cond><name>con3</name><value>4</value></cond></cond_list><commodity_list><commodity_data><commodity>A-e</commodity><name>A-c</name><kind>F</kind><point_num>1</point_num><JMark>N</JMark><month_list><month>201112</month><month>201201</month><month>201202</month></month_list></commodity_data><commodity_data><commodity>AA-e</commodity><name>AA-c</name><kind>F</kind><point_num>3</point_num><JMark>N</JMark><month_list><month>201112</month><month>201203</month><month>201205</month><month>201207</month><month>201209</month><month>201212</month></month_list></commodity_data></commodity_list></data_item><data_item><Publishers>B-list</Publishers><name>BBB</name><MarketJMark>N</MarketJMark><cond_list><cond><name>con1</name><value>2</value></cond><cond><name>con2</name><value>1</value></cond><cond><name>con3</name><value>4</value></cond><cond><name>con4</name><value>8</value></cond></cond_list><commodity_list><commodity_data><commodity>B-e</commodity><name>B-c</name><kind>F</kind><point_num>4</point_num><JMark>N</JMark><month_list><month>201112</month><month>201203</month><month>201206</month<month>201209</month></month_list></commodity_data><commodity_data><commodity>BB-e</commodity><name>BB-c</name><kind>F</kind><point_num>2</point_num><JMark>N</JMark><month_list><month>201112</month><month>201201</month><month>201203</month><month>201205</month><month>201207</month><month>201208</month></month_list></commodity_data></commodity_list></data_item><data_item><Publishers>C-list</Publishers><name>CCC</name><MarketJMark>N</MarketJMark><cond_list><cond><name>con1</name><value>2</value></cond><cond><name>con2</name><value>1</value></cond><cond><name>con3</name><value>4</value></cond></cond_list><commodity_list><commodity_data><commodity>C-e</commodity><name>C-c</name><kind>F</kind><point_num>1</point_num><JMark>N</JMark><month_list><month>201112</month><month>201203</month><month>201206</month><month>201209</month></month_list> </commodity_data></commodity_list></data_item> </Book>
小弟想要在123.txt档中读出以下的结构:
A-list B-list C-list
------- ------- -------
A-e B-e C-e
201112 201112 201112
201201 201203 201203
201202 201206 201206
201209 201209
AA-e BB-e
201112 201112
201203 201201
201205 201203
201207 201205
201209 201207
201212
201208
取得每个list中的每个商品及每个商品的每个月份
请教各位大大,该如何取得呢....