| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 435 人关注过本帖
标题:xml档转成文字档
取消只看楼主 加入收藏
test1130
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2011-12-9
收藏
 问题点数:0 回复次数:0 
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中的每个商品及每个商品的每个月份
请教各位大大,该如何取得呢....



















2011-12-09 13:10
快速回复:xml档转成文字档
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.060530 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved