Пример #1
0
        private void ShowResult(string channel)
        {
            XslCompiledTransform xsl = new XslCompiledTransform();

            xsl.Load(Application.StartupPath + "\\" + Properties.Settings.Default.XSL_FILENAME);

            XPathDocument doc = new XPathDocument(Application.StartupPath + "\\" + Properties.Settings.Default.DATA_FILENAME);
            XPathNavigator navigator = doc.CreateNavigator();

            string xPath = "";

            if (channel == toolStripComboBoxChannel.Items[0].ToString())
            {
                xPath = "items/item";
            }
            else
            {
                xPath = string.Format("items/item[channel='{0}']", channel);
            }

            XPathNodeIterator iterator = navigator.Select(xPath);

            ItemSet set = new ItemSet();

            int count = 0;

            while (iterator.MoveNext())
            {
                Item item = new Item(iterator.Current.OuterXml);
                item.Channel = channel;
                set.Add(item);
                count++;

                if (count == 10)
                {
                    break;
                }
            }

            ItemBase resultItemBase = new ItemBase(set, Application.StartupPath + "\\" + Properties.Settings.Default.RESULT_XML_FILENAME, false);

            resultItemBase.AddItems();
            resultItemBase.Save();

            xsl.Transform(Application.StartupPath + "\\" + Properties.Settings.Default.RESULT_XML_FILENAME,
                Application.StartupPath + "\\" + Properties.Settings.Default.RESULT_HTML_FILENAME);
            wbsMain.Navigate(Application.StartupPath + "\\" + Properties.Settings.Default.RESULT_HTML_FILENAME);
        }