示例#1
0
        public static VirtualRSSXmlFile Load(string FilePath)
        {
            VirtualRSSXmlFile LoadedVirtualRSSXmlFile;

            try
            {
                System.Xml.Linq.XDocument RSSXmlFile  = System.Xml.Linq.XDocument.Load(FilePath);
                System.Xml.Linq.XElement  RSS_Channel = RSSXmlFile.Element("rss").Element("channel");
                LoadedVirtualRSSXmlFile = new VirtualRSSXmlFile(
                    RSS_Channel.Element("title").Value,
                    RSS_Channel.Element("link").Value,
                    RSS_Channel.Element("description").Value,
                    RSS_Channel.Element("generator").Value,
                    RSS_Channel.Element("docs").Value,
                    RSS_Channel.Element("language").Value,
                    RSS_Channel.Element("pubDate").Value,
                    RSS_Channel.Element("lastBuildDate").Value
                    );

                System.Xml.Linq.XElement[] ItemArray = RSS_Channel.Elements("item").ToArray();
                foreach (System.Xml.Linq.XElement Item in ItemArray)
                {
                    item CurrentItem = new item(Item.Element("title").Value, Item.Element("link").Value, Item.Element("description").Value, Item.Element("pubDate").Value);
                    LoadedVirtualRSSXmlFile.ItemList.Add(CurrentItem);
                }
            }
            catch
            {
                LoadedVirtualRSSXmlFile = null;
                throw;
            }
            return(LoadedVirtualRSSXmlFile);
        }
示例#2
0
        static string[] Load(string[] Parameters)
        {
            List <string> Output   = new List <string>();
            string        FilePath = Program.ArrayToString(Parameters, 1);

            if (File.Exists(FilePath))
            {
                VirtualRSSFile1 = VirtualRSSXmlFile.Load(FilePath);

                Output.Add("Info");
                Output.Add("File \"" + FilePath + "\" was loaded.");
                Program.FilePath = FilePath;
            }
            else
            {
                Output.Add("Error");
                Output.Add("File \"" + FilePath + "\" can not be found.");
            }
            return(Output.ToArray());
        }