从XML中获取频道信息

 
  

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Xml;
 6 
 7 namespace TVProject_6
 8 {
 9     public class ChannelManger
10     {
11         public ChannelManger()
12         {
13             Channel=new Dictionary<string,ChannelBase>();
14         }
15 
16         public Dictionary<string,ChannelBase> Channel { get; set; }
17 
18         /// <summary>
19         /// 获取电台信息
20         /// </summary>
21         public void LoadChannels()
22         {
23             XmlDocument xmlDoc = new XmlDocument();
24             xmlDoc.Load("FullChannels.xml");
25             XmlNodeList fullChannelList = xmlDoc.GetElementsByTagName("Channel");
26             foreach (XmlNode fullChannel in fullChannelList)
27             {
28                 ChannelBase cb = ChannelFactory.GetChannel
29                     (fullChannel["tvChannel"].InnerText,
30                     fullChannel["path"].InnerText,
31                     fullChannel["channelType"].InnerText);
32 
33                 Channel.Add(fullChannel["tvChannel"].InnerText, cb);
34             }
35 
36         }
37     }
38 }
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 
 6 namespace TVProject_6
 7 {
 8     /// <summary>
 9     /// 频道基类
10     /// </summary>
11     public abstract class ChannelBase
12     {
13         public ChannelBase()
14         {
15             ProgramLis = new List<TVProgram>();
16         }
17 
18         public ChannelBase(string ChannelType)
19         {
20             ProgramLis = new List<TVProgram>();
21             this.ChannelType = ChannelType;
22         }
23 
24         /// <summary>
25         /// 频道类型
26         /// </summary>
27         public string ChannelType { get; set; }
28 
29         /// <summary>
30         /// 频道名称
31         /// </summary>
32         public string TvChannel { get; set; }
33 
34         /// <summary>
35         /// 频道路径
36         /// </summary>
37         public string Path { get; set; }
38 
39         /// <summary>
40         /// 节目的集合
41         /// </summary>
42         public List<TVProgram> ProgramLis { get; set; }
43 
44         /// <summary>
45         /// 
46         /// </summary>
47         public abstract void LoadProgramList();
48 
49     }
50 }

 

 1 <?xml version="1.0" encoding="utf-8" ?>
 2 <TVChannels>
 3     <Channel>
 4         <channelType>TypeA</channelType> 
 5         <tvChannel>北京电视台</tvChannel>
 6         <path>北京电视台.xml</path>
 7     </Channel>
 8     <Channel>
 9         <channelType>TypeB</channelType>
10         <tvChannel>凤凰卫视</tvChannel>
11         <path>凤凰卫视.xml</path>
12     </Channel>
13   <Channel>
14     <channelType>TypeC</channelType>
15     <tvChannel>湖南卫视</tvChannel>
16     <path>湖南卫视.xml</path>
17   </Channel>
18 </TVChannels>

从XML文件中获取频道信息

转载于:https://www.cnblogs.com/hidelin/archive/2012/09/21/2696256.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值