當前位置: 首頁>>代碼示例>>C#>>正文


C# Dom.XmlDocument類代碼示例

本文整理匯總了C#中Windows.Data.Xml.Dom.XmlDocument的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument類的具體用法?C# XmlDocument怎麽用?C# XmlDocument使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlDocument類屬於Windows.Data.Xml.Dom命名空間,在下文中一共展示了XmlDocument類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnSendNotification

        private void OnSendNotification(object sender, RoutedEventArgs e)
        {
            string xml = @"<toast launch=""developer-defined-string"">
                          <visual>
                            <binding template=""ToastGeneric"">
                              <image placement=""appLogoOverride"" src=""Assets/MicrosoftLogo.png"" />
                              <text>DotNet Spain Conference</text>
                              <text>How much do you like my session?</text>
                            </binding>
                          </visual>
                          <actions>
                            <input id=""rating"" type=""selection"" defaultInput=""5"" >
                          <selection id=""1"" content=""1 (Not very much)"" />
                          <selection id=""2"" content=""2"" />
                          <selection id=""3"" content=""3"" />
                          <selection id=""4"" content=""4"" />
                          <selection id=""5"" content=""5 (A lot!)"" />
                            </input>
                            <action activationType=""background"" content=""Vote"" arguments=""vote"" />
                          </actions>
                        </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            ToastNotification toast = new ToastNotification(doc);
            ToastNotificationManager.CreateToastNotifier().Show(toast);

        }
開發者ID:qmatteoq,項目名稱:dotNetSpainConference2016,代碼行數:29,代碼來源:MainPage.xaml.cs

示例2: UpdateTileAsync

        // Windows Live Tile 
        private async static Task UpdateTileAsync()
        {
            var todayNames = await NamedayRepository.GetTodaysNamesAsStringAsync();
            if (todayNames == null)
                return;
            // Hardcoded XML template for Tile with 2 bindings
            var template =
@"<tile>
 <visual version=""4"">
  <binding template=""TileMedium"">
   <text hint-wrap=""true"">{0}</text>
  </binding>
  <binding template=""TileWide"">
   <text hint-wrap=""true"">{0}</text>
  </binding>
 </visual>
</tile>";
            var content = string.Format(template,todayNames);
            var doc = new Windows.Data.Xml.Dom.XmlDocument();
            doc.LoadXml(content);

            // Create and Update Tile Notification
            TileUpdateManager.CreateTileUpdaterForApplication().
                Update(new TileNotification(doc));
            

        }
開發者ID:yigityesilpinar,項目名稱:Polish-Namedays-Windows-Store-Application,代碼行數:28,代碼來源:MyBackgroundTask.cs

示例3: CompleteTemplate

        public static void CompleteTemplate(XmlDocument xml, string[] text, string[] images = null, string sound = null)
        {
            XmlNodeList slots = xml.SelectNodes("descendant-or-self::image");
            int index = 0;

            if ((images != null) && (slots != null))
            {
                while ((index < images.Length) && (index < slots.Length))
                {
                    ((XmlElement)slots[index]).SetAttribute("src", images[index]);
                    index++;
                }
            }

            if (text != null)
            {
                slots = xml.SelectNodes("descendant-or-self::text");
                index = 0;

                while ((slots != null) && ((index < text.Length) && (index < slots.Length)))
                {
                    slots[index].AppendChild(xml.CreateTextNode(text[index]));
                    index++;
                }
            }

            if (!string.IsNullOrEmpty(sound))
            {
                var audioElement = xml.CreateElement("audio");
                audioElement.SetAttribute("src", sound);
                xml.DocumentElement.AppendChild(audioElement);
            }
        }
開發者ID:chrissimusokwe,項目名稱:TrainingContent,代碼行數:33,代碼來源:TemplateUtility.cs

示例4: NotifyNow

        /// <summary>
        /// Notify immediately using the type of notification
        /// </summary>
        /// <param name="noticeText"></param>
        /// <param name="notificationType"></param>
        public static void NotifyNow(string noticeText, NotificationType notificationType)
        {
            switch (notificationType)
            {
                case NotificationType.Toast:
                    //TODO: Make this hit and deserialize a real XML file
                    string toast = string.Format("<toast>"
                        + "<visual>"
                        + "<binding template = \"ToastGeneric\" >"
                        + "<image placement=\"appLogoOverride\" src=\"Assets\\CompanionAppIcon44x44.png\" />"
                        + "<text>{0}</text>"
                        + "</binding>"
                        + "</visual>"
                        + "</toast>", noticeText);

                    XmlDocument toastDOM = new XmlDocument();
                    toastDOM.LoadXml(toast);
                    ToastNotificationManager.CreateToastNotifier().Show(
                        new ToastNotification(toastDOM));
                    break;
                case NotificationType.Tile:
                    break;
                default:
                    break;
            }
        }
開發者ID:scottroot2,項目名稱:MagicMirror,代碼行數:31,代碼來源:NotificationManager.cs

示例5: actionsToast

 public static async void actionsToast(string title, string content, string id)
 {
     string xml = "<toast>" +
                     "<visual>" +
                         "<binding template=\"ToastGeneric\">" +
                             "<text></text>" +
                             "<text></text>" +
                         "</binding>" +
                     "</visual>" +
                     "<actions>" +
                         "<input id=\"content\" type=\"text\" placeHolderContent=\"請輸入評論\" />" +
                         "<action content = \"確定\" arguments = \"ok" + id + "\" activationType=\"background\" />" +
                         "<action content = \"取消\" arguments = \"cancel\" activationType=\"background\"/>" +
                     "</actions >" +
                  "</toast>";
     // 創建並加載XML文檔
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xml);
     XmlNodeList elements = doc.GetElementsByTagName("text");
     elements[0].AppendChild(doc.CreateTextNode(title));
     elements[1].AppendChild(doc.CreateTextNode(content));
     // 創建通知實例
     ToastNotification notification = new ToastNotification(doc);
     //// 顯示通知
     //DateTime statTime = DateTime.Now.AddSeconds(10);  //指定應傳遞 Toast 通知的時間
     //ScheduledToastNotification recurringToast = new ScheduledToastNotification(doc, statTime);  //創建計劃的 Toast 通知對象
     //ToastNotificationManager.CreateToastNotifier().AddToSchedule(recurringToast); //向計劃中添加 Toast 通知
     ToastNotifier nt = ToastNotificationManager.CreateToastNotifier();
     nt.Show(notification);
 }
開發者ID:RedrockMobile,項目名稱:CyxbsMobile_Win,代碼行數:30,代碼來源:Utils.cs

示例6: PopToast

        public static ToastNotification PopToast(string title, string content, string tag, string group)
        {
            string xml = [email protected]"<toast activationType='foreground'>
                                            <visual>
                                                <binding template='ToastGeneric'>
                                                </binding>
                                            </visual>
                                        </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            var binding = doc.SelectSingleNode("//binding");

            var el = doc.CreateElement("text");
            el.InnerText = title;

            binding.AppendChild(el);

            el = doc.CreateElement("text");
            el.InnerText = content;
            binding.AppendChild(el);

            return PopCustomToast(doc, tag, group);
        }
開發者ID:RasmusTG,項目名稱:Windows-universal-samples,代碼行數:25,代碼來源:ToastHelper.cs

示例7: UpdateTile

        private void UpdateTile()
        {
            var now = DateTime.Now.ToString("HH:mm:ss");
            var xml =
                "<tile>" +
                "  <visual>" +
                "    <binding template='TileSmall'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileMedium'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileWide'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "    <binding template='TileLarge'>" +
                "      <text>" + now + "</text>" +
                "    </binding>" +
                "  </visual>" +
                "</tile>";

            var tileDom = new XmlDocument();
            tileDom.LoadXml(xml);
            var tile = new TileNotification(tileDom);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
        }
開發者ID:secavian,項目名稱:BackgroundTimerLiveTile,代碼行數:26,代碼來源:BackgroundTask.cs

示例8: Hack

 public static void Hack()
 {
     var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
     XmlDocument document = new XmlDocument();
     document.LoadXml(xml);
     tileUpdater.Update(new TileNotification(document));
 }
開發者ID:Mordonus,項目名稱:MALClient,代碼行數:7,代碼來源:StoreLogoWorkaroundHacker.cs

示例9: UpdateTile

        private static void UpdateTile()
        {
            var updateManager = TileUpdateManager.CreateTileUpdaterForApplication();
            updateManager.Clear();
            updateManager.EnableNotificationQueue(true);

            //prepare collection
            List<HolidayItem> eventCollection = _manager.GetHolidayList(DateTime.Now);

            if (eventCollection.Count < 5)
            {
                DateTime dt = DateTime.Now.AddMonths(1);
                List<HolidayItem> s = _manager.GetHolidayList(dt);
                eventCollection.AddRange(s);
            }

            //finalize collection
            eventCollection = (eventCollection.Count <= 5) ? eventCollection : eventCollection.Take(5).ToList();
            
            if (eventCollection.Count > 0)
                foreach (var currEvent in eventCollection)
                {
                    //date to show
                    DateTime date = new DateTime((int)currEvent.Year, (int)currEvent.Month, currEvent.Day);

                    var xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(String.Format(DataBakgroundManager.XML_TEMPLATE, date.ToString("d"), currEvent.HolidayName));

                    var notification = new TileNotification(xmlDocument);
                    updateManager.Update(notification);
                }
        }
開發者ID:Syanne,項目名稱:Holiday-Calendar,代碼行數:32,代碼來源:TileBackgroundTask.cs

示例10: OnNavigatedTo

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            rootPage = MainPage.Current;
            listBox.Items.Add("Index");
            StorageFile storageFile;
            file = "history.xml";
           
            
                storageFile= await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(file);
                XmlLoadSettings loadSettings = new XmlLoadSettings();
                loadSettings.ProhibitDtd = false;
                loadSettings.ResolveExternals = false;
                doc = await XmlDocument.LoadFromFileAsync(storageFile, loadSettings);
                var results = doc.SelectNodes("descendant::result");
                int num_results = 1;
                foreach (var result in results)
                {
                    listBox.Items.Add(num_results.ToString());
                    num_results += 1;
                }

                if (num_results > 1) //show the first history result
                {
                    listBox.SelectedIndex = 1;
                    select_item(0);
                }
            
          


            //rootPage.NotifyUser(doc.InnerText.ToString(), NotifyType.StatusMessage);

        }
開發者ID:MengyuanZhu,項目名稱:Pegasus,代碼行數:33,代碼來源:Previous_Result.xaml.cs

示例11: GetNotificacion

        public override TileNotification GetNotificacion()
        {
            tile = new XmlDocument();            
            tile.LoadXml(stile);

            //System.Diagnostics.Debug.Write(tile.GetXml());

            var nodevisual = tile.GetElementsByTagName("binding");
            if (Title != null && Title != "")
            {
                ((XmlElement)nodevisual[1]).SetAttribute("displayName", this.Title);
            }

            var nodeImage = tile.GetElementsByTagName("image");
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[0]).SetAttribute("src", BackgroundImage.OriginalString);
            ((Windows.Data.Xml.Dom.XmlElement)nodeImage[1]).SetAttribute("src", BackgroundImage.OriginalString);
            //((Windows.Data.Xml.Dom.XmlElement)nodeImage[2]).SetAttribute("src", BackgroundImage.OriginalString);

            var nodeText = tile.GetElementsByTagName("text");
            nodeText[0].InnerText = BackTitle.ToString();
            nodeText[1].InnerText = BackContent.ToString();
            //nodeText[2].InnerText = BackContent.ToString();

            //System.Diagnostics.Debug.Write(this.tile.GetXml());
            var tileNotc = new TileNotification(this.tile);           
            return tileNotc;
        }
開發者ID:karolzak,項目名稱:MVA-Channel9,代碼行數:27,代碼來源:StandardTileData.cs

示例12: SetToatAudio

 private static void SetToatAudio(XmlDocument xml)
 {
     var node = xml.SelectSingleNode("/toast");
     var audio = xml.CreateElement("audio");
     audio.SetAttribute("src", "ms-winsoundevent:Notification.IM");
     node.AppendChild(audio);
 }
開發者ID:chao-zhou,項目名稱:PomodoroTimer,代碼行數:7,代碼來源:NotificationManager.cs

示例13: NavigationHelper_LoadState

        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        async private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            try
            {
                Windows.Storage.StorageFile file = null;
                Windows.Storage.StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                file = await local.GetFileAsync("profile.xml");

                Stream fStream = await file.OpenStreamForReadAsync();
                StreamReader sr = new StreamReader(fStream);
                string result2 = sr.ReadToEnd();
                sr.Dispose();
                fStream.Dispose();
                XmlDocument profile = new XmlDocument();
                profile.LoadXml(result2);
                input_email.Text = profile.DocumentElement.SelectSingleNode("email").InnerText;
                input_username.Text = profile.DocumentElement.SelectSingleNode("username").InnerText;
                input_phone.Text = profile.DocumentElement.SelectSingleNode("phone").InnerText;


            }
            catch
            {
              
            }

        }
開發者ID:bjhamltn,項目名稱:mealaroni_phone_app_windows,代碼行數:38,代碼來源:profile.xaml.cs

示例14: SetTileImageButtonClick

        /// <summary>
        /// Set the application's tile to display a local image file.
        /// After clicking, go back to the start screen to watch your application's tile update.
        /// </summary>
        private void SetTileImageButtonClick(object sender, RoutedEventArgs e)
        {
            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var tileXml = new XmlDocument();
            var title = tileXml.CreateElement("title");
            var visual = tileXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a TileSquareImage. This tells the tile update manager what to expect next.
            var binding = tileXml.CreateElement("binding");
            binding.SetAttribute("template", "TileSquareImage");
            // An image element is then created under the TileSquareImage XML node. The path to the image is specified
            var image = tileXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", @"ms-appx:///Assets/DemoImage.png");

            // All the XML elements are chained up together.
            title.AppendChild(visual);
            visual.AppendChild(binding);
            binding.AppendChild(image);
            tileXml.AppendChild(title);

            // The XML is used to create a new TileNotification which is then sent to the TileUpdateManager
            var tileNotification = new TileNotification(tileXml);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
開發者ID:DavidBurela,項目名稱:Win8Demo-Tiles,代碼行數:32,代碼來源:BlankPage.xaml.cs

示例15: ButtonPinTile_Click

        private async void ButtonPinTile_Click(object sender, RoutedEventArgs e)
        {
            base.IsEnabled = false;

            string ImageUrl = _imagePath.ToString();

            SecondaryTile tile = TilesHelper.GenerateSecondaryTile("App Package Image");
            await tile.RequestCreateAsync();

            string tileXmlString =
                "<tile>"
                + "<visual>"
                + "<binding template='TileSmall'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileMedium'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileWide'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "<binding template='TileLarge'>"
                + "<image src='" + ImageUrl + "' alt='image'/>"
                + "</binding>"
                + "</visual>"
                + "</tile>";

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(tileXmlString);
            TileNotification notifyTile = new TileNotification(xmlDoc);
            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(notifyTile);

            base.IsEnabled = true;
        }
開發者ID:RasmusTG,項目名稱:Windows-universal-samples,代碼行數:34,代碼來源:ScenarioElement.xaml.cs


注:本文中的Windows.Data.Xml.Dom.XmlDocument類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。