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


C# XmlDocument.LoadXml方法代碼示例

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


在下文中一共展示了XmlDocument.LoadXml方法的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: CreateToast

        public static XmlDocument CreateToast(string msg)
        {
            var xDoc = new XDocument(new XElement("toast",
                new XElement("visual",
                new XElement("binding",
                new XAttribute("template", "ToastGeneric"),
                new XElement("text", "BEATS: Alert"),
                new XElement("text", msg)) // binding
                ), // visual
                new XElement("actions",
                new XElement("action",
                new XAttribute("activationType", "foreground"),
                new XAttribute("content", "I'm Okay"),
                new XAttribute("arguments", "yes")),
                new XElement("action",
                new XAttribute("activationType", "foreground"),
                new XAttribute("content", "Help me!"),
                new XAttribute("arguments", "no")))
                // actions
                ));

            var xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(xDoc.ToString());
            return xmlDoc;
        }
開發者ID:leestott,項目名稱:Beats,代碼行數:25,代碼來源:ToastService.cs

示例3: InitAsync

        public async Task InitAsync(string filename = "onboarding.config")
        {
            if (filename == null)
            {
                throw new ArgumentException("Filename cannot be null", nameof(filename));
            }

            if (_xmlDocument == null)
            {
                _xmlDocument = new XmlDocument();

                var item = await ApplicationData.Current.LocalFolder.TryGetItemAsync(filename);
                if (item == null)
                {
                    var projectFolder = await Package.Current.InstalledLocation.GetFolderAsync("IoTOnboardingService");
                    item = await projectFolder.TryGetItemAsync(filename);

                    if (item != null && item.IsOfType(StorageItemTypes.File))
                    {
                        var file = await ((StorageFile)item).CopyAsync(ApplicationData.Current.LocalFolder);
                        var content = await FileIO.ReadTextAsync(file);
                        _xmlDocument.LoadXml(content);
                    }
                }
                else if (item.IsOfType(StorageItemTypes.File))
                {
                    var content = await FileIO.ReadTextAsync((StorageFile)item);
                    _xmlDocument.LoadXml(content);
                }
            }
        }
開發者ID:ch0p57ickz,項目名稱:SunfounderWin10IoT,代碼行數:31,代碼來源:OnboardingConfig.cs

示例4: GetFeedData

 /// <summary>
 /// Get all feed data with a structure according to <see cref="ITMUtils.NewsParsing.NewsStruct" />
 /// </summary>
 /// <returns>All feed data into a <see cref="List{Structure}"/> format</returns>
 public async static Task<ObservableCollection<NewsStruct>> GetFeedData()
 {
     ObservableCollection<NewsStruct> result = new ObservableCollection<NewsStruct>();
     HttpClient client = new HttpClient();
     string xml = await client.GetStringAsync(SourceUrl);
     XmlDocument xdoc = new XmlDocument();
     xdoc.LoadXml(xml);
     XmlNodeList nodes = xdoc.SelectNodes(TitlePath);
     foreach (IXmlNode item in nodes)
     {
         result.Add(new NewsStruct() { Title = item.InnerText });
     }
     Regex rgx = new Regex("src=\".+?\"");
     xdoc.LoadXml(xml);
     nodes = xdoc.SelectNodes(DescriptionPath);
     int count = 0;
     string text = string.Empty;
     foreach (IXmlNode item in nodes)
     {
         text = item.NextSibling.NextSibling.InnerText;
         result[count].ImgSource = rgx.Matches(text)[0].Value.Replace("src=\"", string.Empty).Replace("\"", string.Empty);
         result[count].Content = Regex.Replace(Regex.Replace(text, "<.*?>", string.Empty), "&.*?;", string.Empty);
         result[count].EncodedString = text;
         count++;
     }
     nodes = xdoc.SelectNodes(PublishDatePath);
     count = 0;
     foreach (IXmlNode item in nodes)
     {
         result[count].PublishDate = DateTime.Parse(item.InnerText).ToLocalTime();
         result[count].Author = "Autor: " + item.NextSibling.NextSibling.InnerText;
         count++;
     }
     return result;
 }
開發者ID:Anvyl,項目名稱:ITMoldova,代碼行數:39,代碼來源:Parser.cs

示例5: UpdateTile

        async private Task UpdateTile()
        {
            string server = settings.server;
            string uid = settings.uid;

            if (server.Length == 0 || uid.Length == 0) return;

            string url = "http://" + server + "/humidor/mobile.php?id=" + uid + "&page=3";

            await doWebReq(url);
            if (failed) await doWebReq(url);

            if (content == null || content.Length == 0) return;

            string xml = getXML(content);

            XmlDocument x = new XmlDocument();
            try
            {
                x.LoadXml(xml);
            }
            catch (Exception ex)
            {
                if (!_debug) return;
                x.LoadXml(getXML("Error Parsing WebXml"));
            }

            var tileNotification = new TileNotification(x);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);
        }
開發者ID:wansley,項目名稱:humidor.net,代碼行數:30,代碼來源:FirstTask.cs

示例6: TryUpdateLiveTileAsync

        public void TryUpdateLiveTileAsync(String liveTileText, string imageUrl)
        {
            try
            {
                TileUpdateManager.CreateTileUpdaterForApplication()
                                 .EnableNotificationQueue(true);

                var liveTileXml = @"<tile>
                                      <visual version=""2"">
                                        <binding template=""TileSquare310x310ImageAndTextOverlay01"">
                                          <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                          <text id=""1"">" + liveTileText + @"</text>
                                        </binding>
                                      </visual>
                                    </tile>";

                var wideLiveTileXml = @"<tile>
                                          <visual version=""2"">
                                            <binding template=""TileWide310x150PeekImage03"" fallback=""TileWidePeekImage03"">
                                              <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                              <text id=""1"">" + liveTileText + @"</text>
                                            </binding>
                                          </visual>
                                        </tile>";

                var squareLiveTileXml = @"<tile>
                                           <visual version=""2"">
                                             <binding template=""TileSquare150x150PeekImageAndText04"" fallback=""TileSquarePeekImageAndText04"">
                                               <image id=""1"" src=""" + imageUrl + @""" alt=""alt text""/>
                                               <text id=""1"">" + liveTileText + @"</text>
                                             </binding>
                                           </visual>
                                         </tile>";

                var tileXml = new XmlDocument();

                tileXml.LoadXml(liveTileXml);
                var tileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);

                tileXml.LoadXml(wideLiveTileXml);
                var wideTileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(wideTileNotification);

                tileXml.LoadXml(squareLiveTileXml);
                var squareTileNotification = new TileNotification(tileXml);
                TileUpdateManager.CreateTileUpdaterForApplication().Update(squareTileNotification);

                TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(new ScheduledTileNotification(tileXml, new DateTimeOffset(0, 0,0,0,0,30,0, new TimeSpan(0,0,30))));
            }
            catch
            {
                // do nothing, it doesn't matter!
            }
        }
開發者ID:oferhaze,項目名稱:Ferrari,代碼行數:55,代碼來源:LiveTileService.cs

示例7: SetLiveTileToSingleImage

            static async void SetLiveTileToSingleImage(string wideImageFileName, string mediumImageFileName)
            {
                // Construct the tile content as a string
                string content = [email protected]"
                                <tile>
                                    <visual> 
                                        <binding template='TileSquareImage'>
                                           <image id='1' src='ms-appdata:///local/{mediumImageFileName}' />
                                        </binding> 
                                         <binding  template='TileWideImage' branding='none'>
                                           <image id='1' src='ms-appdata:///local/{wideImageFileName}' />
                                        </binding>
 
                                    </visual>
                                </tile>";

            SecondaryTile sec = new SecondaryTile("tile", "","prof2", new Uri("ms-appdata:///local/{mediumImageFileName}"), TileSize.Square150x150);
            await sec.RequestCreateAsync();
                // Load the string into an XmlDocument
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                // Then create the tile notification
                var notification = new TileNotification(doc);
                TileUpdateManager.CreateTileUpdaterForSecondaryTile(sec.TileId).Update(notification);

        }
開發者ID:Romaxaqaz,項目名稱:Onliner,代碼行數:27,代碼來源:LiveTileBuilder.cs

示例8: OnUpdateTileClicked

        public void OnUpdateTileClicked(object sender, RoutedEventArgs e)
        {
            string xml = @"<tile>
        <visual>
        <binding template=""TileMedium"">
            <group>
            <subgroup>
                <text hint-style=""subtitle"">John Doe</text>
                <text hint-style=""subtle"">Photos from our trip</text>
                <text hint-style=""subtle"">Thought you might like to see all of</text>
            </subgroup>
            </group>
            <group>
            <subgroup>
                <text hint-style=""subtitle"">Jane Doe</text>
                <text hint-style=""subtle"">Questions about your blog</text>
                <text hint-style=""subtle\"">Have you ever considered writing a</text>
            </subgroup>
            </group>
        </binding>
        </visual>
    </tile>";



            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);
            TileNotification notification = new TileNotification(doc);
            TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication();

            updater.Update(notification);
        }
開發者ID:Janisku7,項目名稱:Windows10-Samples,代碼行數:32,代碼來源:MainPage.xaml.cs

示例9: DisplayToast

        public static ToastNotification DisplayToast(string content)
        {
            string xml = [email protected]"<toast activationType='foreground'>
                                            <visual>
                                                <binding template='ToastGeneric'>
                                                    <text>Extended Execution</text>
                                                </binding>
                                            </visual>
                                        </toast>";

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

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

            var el = doc.CreateElement("text");
            el.InnerText = content;
            binding.AppendChild(el); //Add content to notification

            var toast = new ToastNotification(doc);

            ToastNotificationManager.CreateToastNotifier().Show(toast); //Show the toast

            return toast;
        }
開發者ID:AJ-COOL,項目名稱:Windows-universal-samples,代碼行數:25,代碼來源:SampleConfiguration.cs

示例10: 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

示例11: PopCustomToast

        /// <summary>
        /// Show notification by custom xml
        /// </summary>
        /// <param name="xml">notification xml</param>
        /// <param name="tag">tag</param>
        /// <param name="group">group</param>
        /// <returns>ToastNotification</returns>
        public static ToastNotification PopCustomToast(string xml, string tag, string group)
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            return PopCustomToast(doc, tag, group);
        }
開發者ID:EdiWang,項目名稱:UWP-Helpers,代碼行數:14,代碼來源:ToastHelper.cs

示例12: 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

示例13: 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

示例14: 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

示例15: btnLocatToastWithAction_Click

        private void btnLocatToastWithAction_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            string title = "Você recebeu uma imagem";
            string content = "Check this out, Happy Canyon in Utah!";
            string image = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-71-81-permanent/2727.happycanyon1_5B00_1_5D00_.jpg";

            string toastActions =
            [email protected]"<toast>
                <visual>
                    <binding template='ToastGeneric'>
                        <text>{title}</text>
                        <text>{content}</text>
                        <image src='{image}' placement='appLogoOverride' hint-crop='circle'/>
                    </binding>
                </visual>
                <actions>
                    <input id = 'message' type = 'text' placeholderContent = 'reply here' />
                    <action activationType = 'background' content = 'reply' arguments = 'reply' />
                    <action activationType = 'foreground' content = 'video call' arguments = 'video' />
                </actions>
            </toast>";

            XmlDocument x = new XmlDocument();
            x.LoadXml(toastActions);
            ToastNotification t = new ToastNotification(x);
            ToastNotificationManager.CreateToastNotifier().Show(t);
        }
開發者ID:rogeriohc,項目名稱:NavPaneApp1,代碼行數:27,代碼來源:Page3.xaml.cs


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