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


C# XmlDocument.CreateElement方法代碼示例

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


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

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

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

示例3: doAuditing

        private async void doAuditing(Order order)
        {
            List<OrderItem> ageRestrictedItems = findAgeRestrictedItems(order);
            if (ageRestrictedItems.Count > 0)
            {
                try
                {
                    StorageFile file = await KnownFolders.DocumentsLibrary.CreateFileAsync("audit-" + order.OrderID.ToString() + ".xml");
                    if (file != null)
                    {
                        XmlDocument doc = new XmlDocument();
                        XmlElement root = doc.CreateElement("Order");
                        root.SetAttribute("ID", order.OrderID.ToString());
                        root.SetAttribute("Date", order.Date.ToString());

                        foreach (OrderItem orderItem in ageRestrictedItems)
                        {
                            XmlElement itemElement = doc.CreateElement("Item");
                            itemElement.SetAttribute("Product", orderItem.Item.Name);
                            itemElement.SetAttribute("Description", orderItem.Item.Description);
                            root.AppendChild(itemElement);
                        }

                        doc.AppendChild(root);

                        await doc.SaveToFileAsync(file);
                    }
                    else
                    {
                        MessageDialog dlg = new MessageDialog(String.Format("Unable to save to file: {0}", file.DisplayName), "Not saved");
                        dlg.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    MessageDialog dlg = new MessageDialog(ex.Message, "Exception");
                    dlg.ShowAsync();
                }
                finally 
                {
                    if (this.AuditProcessingComplete != null) 
                    {
                        this.AuditProcessingComplete(String.Format(
                            "Audit record written for Order {0}", order.OrderID)); 
                    }
                }
            }
        }
開發者ID:RajaBellebon,項目名稱:edX,代碼行數:48,代碼來源:Auditor.cs

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

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

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

示例7: CreateTileTemplate

        public static XmlDocument CreateTileTemplate(Wallpaper wallpaper)
        {
            XmlDocument document = new XmlDocument();

            // tile 根節點。
            XmlElement tile = document.CreateElement("tile");
            document.AppendChild(tile);

            // visual 元素。
            XmlElement visual = document.CreateElement("visual");
            tile.AppendChild(visual);

            // Medium,150x150。
            {
                // binding
                XmlElement binding = document.CreateElement("binding");
                binding.SetAttribute("template", "TileMedium");
                visual.AppendChild(binding);

                // image
                XmlElement image = document.CreateElement("image");
                image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(150, 150)));
                image.SetAttribute("placement", "background");
                binding.AppendChild(image);

                // text
                XmlElement text = document.CreateElement("text");
                text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info));
                text.SetAttribute("hint-wrap", "true");
                binding.AppendChild(text);
            }

            // Wide,310x150。
            {
                // binding
                XmlElement binding = document.CreateElement("binding");
                binding.SetAttribute("template", "TileWide");
                visual.AppendChild(binding);

                // image
                XmlElement image = document.CreateElement("image");
                image.SetAttribute("src", wallpaper.GetOriginalUrl(new WallpaperSize(310, 150)));
                image.SetAttribute("placement", "background");
                binding.AppendChild(image);

                // text
                XmlElement text = document.CreateElement("text");
                text.AppendChild(document.CreateTextNode(wallpaper.Archive.Info));
                text.SetAttribute("hint-wrap", "true");
                binding.AppendChild(text);
            }

            return document;
        }
開發者ID:higankanshi,項目名稱:MSDevUnion.BingWallpaper,代碼行數:54,代碼來源:TileHelper.cs

示例8: GetParentElement

        protected virtual XmlElement GetParentElement(XmlDocument toastContent, string parentName)
        {
            var root = toastContent.DocumentElement;

            var parentElement = root.SelectSingleNode(parentName) as XmlElement;
            if (parentElement == null)
            {
                parentElement = toastContent.CreateElement(parentName);
                root.AppendChild(parentElement);
            }
            return parentElement;
        }
開發者ID:CuteITGuy,項目名稱:CB.Windows.UI,代碼行數:12,代碼來源:ToastElement.cs

示例9: CreateCommandElement

 private XmlElement CreateCommandElement(XmlDocument toastContent)
 {
     var commandElement = toastContent.CreateElement("command");
     if (CommandId != ToastCommandId.None)
     {
         commandElement.SetAttribute("id", CommandId.ToString().ToLower());
     }
     if (!string.IsNullOrWhiteSpace(Arguments))
     {
         commandElement.SetAttribute("arguments", Arguments);
     }
     return commandElement;
 }
開發者ID:CuteITGuy,項目名稱:CB.Windows.UI,代碼行數:13,代碼來源:ToastCommand.cs

示例10: SendToast

        public static void SendToast(string txt, string imgurl = "")
        {
            if (toaster.Setting != NotificationSetting.Enabled) return;

            // It is possible to start from an existing template and modify what is needed.
            // Alternatively you can construct the XML from scratch.
            var toastXml = new Windows.Data.Xml.Dom.XmlDocument();
            var title = toastXml.CreateElement("toast");
            var visual = toastXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a ToastImageAndText01. This tells the toast notification manager what to expect next.
            var binding = toastXml.CreateElement("binding");
            binding.SetAttribute("template", "ToastImageAndText01");

            // An image element is then created under the ToastImageAndText01 XML node. The path to the image is specified
            var image = toastXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", imgurl);

            // A text element is created under the ToastImageAndText01 XML node.
            var text = toastXml.CreateElement("text");
            text.SetAttribute("id", "1");
            text.InnerText = txt;

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

            toastXml.AppendChild(title);

            // Create a ToastNotification from our XML, and send it to the Toast Notification Manager
            var toast = new ToastNotification(toastXml);
            toaster.Show(toast);
        }
開發者ID:Amrykid,項目名稱:Hanasu,代碼行數:38,代碼來源:NotificationsController.cs

示例11: InitDataBase

        /// <summary>
        /// Init the Connector. Create the File if not exist, or open and load it.
        /// </summary>
        public async void InitDataBase()
        {
            var localFolder = ApplicationData.Current.LocalFolder;
            _rootDocument = new XmlDocument();

            _databaseXmlFile = await localFolder.CreateFileAsync("TaskTimeRecorder.xml", CreationCollisionOption.OpenIfExists);
            var fileContent = await FileIO.ReadTextAsync(_databaseXmlFile);

            if (fileContent == "")
            {
                var rootElement = _rootDocument.CreateElement("TaskTimeRecorder");
                var tasksElement = _rootDocument.CreateElement("Tasks");

                rootElement.AppendChild(tasksElement);
                _rootDocument.AppendChild(rootElement);

                _rootDocument.SaveToFileAsync(_databaseXmlFile);
            }
            else
            {
                _rootDocument.LoadXml(fileContent);
                LoadAllTasks();
            }
        }
開發者ID:nhammerl,項目名稱:TaskTimeRecorder,代碼行數:27,代碼來源:XmlDatabaseConnector.cs

示例12: NotificationImageButton_Click

        /// <summary>
        /// Raises a image toast notification locally.
        /// IMPORTANT: if copying this into your own application, ensure that "Toast capable" is enabled in the application manifest
        /// </summary>
        private void NotificationImageButton_Click(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 toastXml = new XmlDocument();
            var title = toastXml.CreateElement("toast");
            var visual = toastXml.CreateElement("visual");
            visual.SetAttribute("version", "1");
            visual.SetAttribute("lang", "en-US");

            // The template is set to be a ToastImageAndText01. This tells the toast notification manager what to expect next.
            var binding = toastXml.CreateElement("binding");
            binding.SetAttribute("template", "ToastImageAndText01");

            // An image element is then created under the ToastImageAndText01 XML node. The path to the image is specified
            var image = toastXml.CreateElement("image");
            image.SetAttribute("id", "1");
            image.SetAttribute("src", @"Assets/DemoImage.png");

            // A text element is created under the ToastImageAndText01 XML node.
            var text = toastXml.CreateElement("text");
            text.SetAttribute("id", "1");
            text.InnerText = "Another sample toast. This time with an image";

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

            toastXml.AppendChild(title);

            // Create a ToastNotification from our XML, and send it to the Toast Notification Manager
            var toast = new ToastNotification(toastXml);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
開發者ID:DavidBurela,項目名稱:Win8Demo-Notifications,代碼行數:40,代碼來源:BlankPage.xaml.cs

示例13: getList

        public List<string> getList(string franchUserID, string password,
            string userID, string userKey, string username, string userrole,
            string userstatus, string usertype)
        {
            List<string> servicesNames = new List<string>();


            XmlDocument doc = new XmlDocument();

            XmlElement el = (XmlElement)doc.AppendChild(doc.CreateElement("soapenv:Header"));
            el.SetAttribute("Bar", "some & value");



            return servicesNames;
        }
開發者ID:webashlar1234,項目名稱:BusIndia30-06-15,代碼行數:16,代碼來源:getListService.cs

示例14: CheckGoodsFile

        private async void CheckGoodsFile()
        {
            try
            {
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.GetFileAsync("Goods.xml");
            }
            catch(IOException e)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(e.Message);
#endif
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.CreateFileAsync("Goods.xml", CreationCollisionOption.ReplaceExisting);
                XmlDocument doc = new XmlDocument();
                XmlElement ele = doc.CreateElement("orders");
                ele.InnerText = "";
                doc.AppendChild(ele);
                await doc.SaveToFileAsync(storageFile);
            }
            try
            {
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.GetFileAsync("ShoppingCart.xml");
            }
            catch (IOException e)
            {
#if DEBUG
                System.Diagnostics.Debug.WriteLine(e.Message);
#endif
                Windows.Storage.StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
                Windows.Storage.StorageFile storageFile = await storageFolder.CreateFileAsync("ShoppingCart.xml", CreationCollisionOption.ReplaceExisting);
                XmlDocument doc = new XmlDocument();
                XmlElement ele = doc.CreateElement("goods");
                ele.InnerText = "";
                doc.AppendChild(ele);
                await doc.SaveToFileAsync(storageFile);
            }
        }
開發者ID:DXChinaTE,項目名稱:O2OApp,代碼行數:39,代碼來源:App.xaml.cs

示例15: Toast

        public Toast(string header, string body)
        {
            XmlDocument doc = new XmlDocument(); ;
            doc = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            var test = doc.DocumentElement;
            XmlElement audio = doc.CreateElement("audio");
            if (!string.IsNullOrEmpty(sound.FileCheck(header))) audio.SetAttribute("silent", "true");
            test.AppendChild(audio);
            doc = test.OwnerDocument;

            var toastXml = doc;

            var stringElements = toastXml.GetElementsByTagName("text");
            if (stringElements.Length == 2)
            {
                stringElements[0].AppendChild(toastXml.CreateTextNode(header));
                stringElements[1].AppendChild(toastXml.CreateTextNode(body));
            }

            this.toast = new ToastNotification(toastXml);
        }
開發者ID:Sinwee,項目名稱:KanColleViewer,代碼行數:22,代碼來源:Toast.cs


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