只好写这么个东西,再用XSL显示了。
代码还没完全写好,往集合中添加ITEM时,后面的项总会把前面的几个覆盖掉,最终就只剩下最后一个ITEM了,不过COUNT是对的。
贴一部分代码:

下面的是生成RSS的类,不过有问题,再向频道添加ITEM的时候,后一个会覆盖前一个。
1
using System;
2
using System.Collections;
3
using System.Collections.Generic;
4
using System.Text;
5
using System.IO;
6
using Rss;
7
namespace buildSiteMap
8
{
9
public class buildxml
10
{
11
private seachFiles sf = new seachFiles();
12
private string siteurl;
13
private string filepath;
14
public buildxml()
15
{
16
sf.Filepath = "";
17
sf.Filetypes = "";
18
filepath = "";
19
siteurl = "";
20
}
21
public buildxml(string filep,string filet,string url)
22
{
23
sf.Filepath = filep;
24
sf.Filetypes = filet;
25
siteurl=url;
26
filepath = filep;
27
filepath = this.ismenusite(filepath);
28
}
29
public string Siteurl
30
{
31
get { return this.siteurl; }
32
set { this.siteurl = value; }
33
}
34
public bool savexml()
35
{
36
try
37
{
38
Rss.RssFeed rf = new RssFeed();
39
rf.Encoding = System.Text.Encoding.GetEncoding("gb2312");
40
rf.Version = RssVersion.RSS20;
41
Rss.RssItem ri = new RssItem();
42
Rss.RssChannel rc = new RssChannel();
43
rc.Title = "china tour";
44
rc.Description = "china tour|tibet tour|sichuan tour";
45
siteurl = this.getsiteurl(siteurl);
46
siteurl = this.iswebsite(siteurl);
47
rc.Link = new Uri(siteurl);
48
49
rc.PubDate = DateTime.Now;
50
System.Collections.ArrayList arr = new System.Collections.ArrayList();
51
arr = sf.getFilePaths();
52
string tempstr = "";
53
foreach(FileInfo fi in arr)
54
{
55
System.Console.Out.WriteLine(fi.Name);
56
ri.Title = fi.Name.ToString();// this.getfilename();
57
tempstr = fi.FullName.ToString();
58
tempstr = tempstr.Replace(filepath, siteurl);
59
ri.Link = new Uri(tempstr);
60
ri.PubDate = fi.LastWriteTime;
61
rc.Items.Add(ri);
62
}
63
rf.Channels.Add(rc);
64
string sitename = this.getsitename(siteurl.ToString());
65
rf.Write(filepath+sitename+".xml");
66
}
67
catch (Exception ex)
68
{
69
System.Console.Out.Write("保存RSS时出错"+ex.Message.ToString());
70
return false;
71
}
72
return true;
73
}
74
private string iswebsite(string linkurl)
75
{
76
string c=linkurl.Substring(linkurl.Length - 1);
77
return c.Equals("/") ? linkurl : linkurl + "/";
78
}
79
private string ismenusite(string linkurl)
80
{
81
string c = linkurl.Substring(linkurl.Length - 1);
82
return c.Equals("\\") ? linkurl : linkurl + "\\";
83
}
84
private string getsitename(string siteurl)
85
{
86
87
return siteurl.Split('.')[1].ToString();
88
}
89
private string getsiteurl(string siteurl)
90
{
91
return siteurl == "" ? "http://www.lutoo.com" : siteurl;
92
}
93
private string getfilename(string filename)
94
{
95
return filename.Split('.')[0].ToString();
96
}
97
}
98
}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98
