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); }
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; }
public ToastText(string message, ToastTemplateType type) { xmlDoc = ToastNotificationManager.GetTemplateContent(type); var textTag = xmlDoc.GetElementsByTagName("text").First(); textTag.AppendChild(xmlDoc.CreateTextNode(message)); }
private static void SetTileImages(XmlDocument xmlDocument, params string[] images) { if (images != null) { try { var imageElements = xmlDocument.GetElementsByTagName("image").ToArray(); for (int n = 0; n < images.Length; n++) { var imageElement = imageElements[n] as XmlElement; if (images[n].StartsWith("ms-appx:", StringComparison.OrdinalIgnoreCase) || images[n].StartsWith("ms-appdata:", StringComparison.OrdinalIgnoreCase)) { imageElement.SetAttribute("src", images[n]); } else { imageElement.SetAttribute("src", String.Format("ms-appx:///Assets/{0}", images[n])); } } } catch (Exception ex) { Debug.WriteLine(ex); } } }
public async Task<MembersReport> RefreshClubMembers() { MembersReport membersReport; var responseMessage = await ExecuteMembersRequest(); var xml = await responseMessage.Content.ReadAsStringAsync(); if (responseMessage.StatusCode == HttpStatusCode.InternalServerError && xml.Contains("InvalidSessionFault")) { var report = await _authenticationService.LoginWithStoredCredentials(); if (report.Successful) await RefreshClubMembers(); else { membersReport = new MembersReport(false, null) { Error = report.Error }; return membersReport; } } XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); var members = new List<Member>(); var nodeList = doc.GetElementsByTagName("b:MemberIdentification"); foreach (var memberNode in nodeList) { var node = memberNode.ChildNodes.FirstOrDefault(c => c.NodeName == "Name"); members.Add(new Member(node.InnerText)); } var storageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("members.txt", CreationCollisionOption.OpenIfExists); await FileIO.WriteTextAsync(storageFile, JsonConvert.SerializeObject(members)); membersReport = new MembersReport(true, members); return membersReport; }
private async void SaveAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e) { var actieAnswer = false; if (Validate()) { if (actieObject != null) { actieObject.Beschrijving = Beschrijving.Text; var dateObject = Datum.Date.Date.ToString().Substring(0, 10) + " " + Time.Time.ToString(); DateTime myDateObject = DateTime.Parse(dateObject); actieObject.GeldigTot = myDateObject; actieAnswer = await actieViewModel.bewerkActieAsync(actieObject); if (actieAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Actie")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(actieObject.Beschrijving + " aangepast")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } else { var date = Datum.Date.Date.ToString().Substring(0, 10) + " " + Time.Time.ToString(); DateTime myDate = DateTime.Parse(date); Actie actie = new Actie( Beschrijving.Text, myDate, Int32.Parse(bedrijf) ); actieAnswer = await actieViewModel.addActieAsync(actie); if (actieAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Actie")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(actie.Beschrijving + " werd toegevoegd aan je acties")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } } }
protected void WriteAutoCommandsToHandler(XmlDocument voiceXml) { var commandSet = voiceXml.GetElementsByTagName("Command").Where(n => n.Attributes.GetNamedItem("Name").NodeValue.ToString().StartsWith("auto")); foreach (var c in commandSet) { VoiceHandler.AddCommand(GenerateAutoVoiceCommand(c)); } }
private static void AppendImageToNotification(ToastContent toastContent, XmlDocument xml) { var imageElements = xml.GetElementsByTagName(ImageNode); if (!imageElements.Any()) return; ((XmlElement)imageElements[0]).SetAttribute(SrcAttr, toastContent.Image ?? string.Empty); ((XmlElement)imageElements[0]).SetAttribute(AltAttr, toastContent.AltText ?? string.Empty); }
public static BlockCollection ConvertHtmlToRtf(string html) { RichTextBlock parent = new RichTextBlock(); XmlDocument document = new XmlDocument(); document.LoadXml(html); ParseElement((XmlElement)(document.GetElementsByTagName("body")[0]), new RichTextBlockTextContainer(parent)); return parent.Blocks; }
private static void OnHtmlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs) { RichTextBlock parent = (RichTextBlock)sender; parent.Blocks.Clear(); XmlDocument document = new XmlDocument(); document.LoadXml((string)eventArgs.NewValue); ParseElement((XmlElement)(document.GetElementsByTagName("body")[0]), new RichTextBlockTextContainer(parent)); }
public static Chapter ParseChapter(string html) { Chapter chapter = new Chapter(); XmlDocument document = new XmlDocument(); document.LoadXml(html); ParseElement((XmlElement)(document.GetElementsByTagName("body")[0]), chapter, Style.NORMAL); return chapter; }
private void UpdateTile(MainListboxModel item) { var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.EnableNotificationQueue(true); updater.Clear(); Windows.Data.Xml.Dom.XmlDocument xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150PeekImageAndText01); xml.GetElementsByTagName("text")[0].InnerText = item.title; xml.GetElementsByTagName("text")[1].InnerText = item.subtitle; xml.GetElementsByTagName("text")[3].InnerText = "Heerlijk " + item.category; XmlNodeList squareImageElements = xml.GetElementsByTagName("image"); XmlElement squareImageElement = (XmlElement)squareImageElements.Item(0); squareImageElement.SetAttribute("src", imgUrl + item.image); updater.Update(new TileNotification(xml)); }
void ToastNotifier() { ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; Windows.Data.Xml.Dom.XmlDocument toastxml = ToastNotificationManager.GetTemplateContent(toastTemplate); Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastxml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastxml.CreateTextNode("You are near a room")); ToastNotification toast = new ToastNotification(toastxml); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void UpdateTile(string infoString) { var updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.EnableNotificationQueue(true); updater.Clear(); Windows.Data.Xml.Dom.XmlDocument xml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04); xml.GetElementsByTagName("text")[0].InnerText = infoString; updater.Update(new TileNotification(xml)); }
private void ShowToastNotification() { for (int i = 0; i < ViewModel.AllItems.Count; i++) { if (ViewModel.AllItems[i].date.Day == DateTime.Now.Day) { ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode(ViewModel.AllItems[i].title + "\n" + ViewModel.AllItems[i].description)); Windows.Data.Xml.Dom.XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((Windows.Data.Xml.Dom.XmlElement)toastImageAttributes[0]).SetAttribute("src", "Assets//2015071504.jpg"); Windows.Data.Xml.Dom.XmlElement audio = toastXml.CreateElement("audio"); ((Windows.Data.Xml.Dom.XmlElement)toastNode).SetAttribute("duration", "long"); audio.SetAttribute("silent", "true"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } }
public static async Task <Podcast> ParseAsync(string url, bool checkDownloads, string login = null, string password = null) { try { var data = await CoreTools.DownloadStringAsync(url, true, login, password); var document = new Windows.Data.Xml.Dom.XmlDocument(); try { document.LoadXml(data); } catch { data = await CoreTools.DownloadStringAsync(url, false, login, password); document.LoadXml(data); } var channel = document.GetElementsByTagName("channel")[0] as Windows.Data.Xml.Dom.XmlElement; var result = new Podcast { Title = channel.GetChildNodeTextValue("title", "").Sanitize(), Description = channel.GetChildNodeTextValue("description", "").Sanitize(), Link = channel.GetChildNodeTextValue("link", ""), Image = channel.GetChildNodeAttribute("itunes:image", "href", ""), FeedUrl = url, Login = login, Password = password }; if (string.IsNullOrEmpty(result.Image)) { result.LocalImage = "ms-appx:///Assets/IconFull.png"; } if (string.IsNullOrEmpty(result.Description)) { result.Description = channel.GetChildNodeTextValue("itunes:summary", "").Sanitize(); } await result.ParseAsync(document, false, checkDownloads); result.ReOrder(); return(result); } catch { return(null); } }
/* public static List<Apps> listApps() { List<AppInfo> mFileList = new List<AppInfo>(); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(context); Resources res = context.getResources(); AssetManager am = res.getAssets(); string appList[], iconList[]; try { appList = am.list("Apps"); iconList = am.list("Icons"); if (appList != null) { for (int i = 0; i < appList.length; i++) { AppInfo app = new AppInfo(); app.Name = (appList[i].substring(0, appList[i].indexOf(".buildmlearn"))); if (!SP.contains(app.Name)) { SharedPreferences.Editor editor1 = SP.edit(); editor1.putBoolean(app.Name, false); editor1.commit(); continue; } if (!SP.getBoolean(app.Name, false)) continue; app.AppIcon = BitmapFactory.decodeStream(am.open("Icons/" + iconList[i])); BufferedReader br = new BufferedReader(new InputStreamReader(context.getAssets().open("Apps/" + appList[i]))); string type = br.readLine(); if (type.contains("InfoTemplate")) app.Type = 0; else if (type.contains("QuizTemplate")) app.Type = 2; else if (type.contains("FlashCardsTemplate")) app.Type = 1; else if (type.contains("SpellingTemplate")) app.Type = 3; br.readLine(); type = br.readLine(); int x = type.indexOf("<name>") + 6; int y = type.indexOf("<", x + 1); app.Author = type.substring(x, y); mFileList.add(app); } } } catch (IOException e) { e.printStackTrace(); } AppList = mFileList; return mFileList; } */ /// <summary> /// It reads the Info App-Template, from the .buildmlearn file. /// </summary> /// <param name="fileName">Name of the file</param> public static void readInfoFile(string fileName) { try { InfoModel model = InfoModel.getInstance(); List<string> infoTitleList = new List<string>(); List<string> infoDescriptionList = new List<string>(); XmlDocument doc = new XmlDocument(); doc.LoadXml(XDocument.Load("Assets/Apps/" + fileName + ".xml").ToString()); model.setInfoName(doc.GetElementsByTagName("title").ElementAt(0).InnerText.Trim()); model.setInfoDescription(doc.GetElementsByTagName("description").ElementAt(0).InnerText.Trim()); string[] author = doc.GetElementsByTagName("author").ElementAt(0).InnerText.Split('\n'); model.setInfoAuthor(author[1].Trim()); model.setInfoAuthorEmail(author[2].Trim()); model.setInfoVersion(doc.GetElementsByTagName("version").ElementAt(0).InnerText.Trim()); XmlNodeList info_title = doc.GetElementsByTagName("item_title"); XmlNodeList info_description = doc.GetElementsByTagName("item_description"); for (int i = 0; i < info_title.Length; i++) { infoTitleList.Add(info_title.ElementAt(i).InnerText.Trim()); infoDescriptionList.Add(info_description.ElementAt(i).InnerText.Trim()); } model.setInfoTitleList(infoTitleList); model.setInfoDescriptionList(infoDescriptionList); } catch (Exception e) { } }
//查询天气 async void WeatherQuery() { if (cityName.Text == "") { return; } string url = "http://api.avatardata.cn/Weather/Query?key=1a2fa02c4cf34aafbb7ff83904a6ac6e&cityname=" + cityName.Text + "&dtype=XML"; HttpClient client = new HttpClient(); string response = await client.GetStringAsync(url); Windows.Data.Xml.Dom.XmlDocument document = new Windows.Data.Xml.Dom.XmlDocument(); document.LoadXml(response); Windows.Data.Xml.Dom.XmlNodeList list = document.GetElementsByTagName("temperature"); if (list.Length == 0) { var ii = new MessageDialog("The city is not exit!").ShowAsync(); } else { IXmlNode node = list.Item(0); string i = node.InnerText; if (i != "") { list = document.GetElementsByTagName("info"); node = list.Item(0); weatherText.Text = "天气: " + node.InnerText; list = document.GetElementsByTagName("temperature"); node = list.Item(0); weatherText.Text += " 温度: " + node.InnerText + "摄氏度"; } else { var ii = new MessageDialog("Error!").ShowAsync(); } } }
private void ShowToastNotification(string title, string content) { ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier(); Windows.Data.Xml.Dom.XmlDocument toastDoc = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02); XmlNodeList toastNodeList = toastDoc.GetElementsByTagName("text"); toastNodeList.Item(0).AppendChild(toastDoc.CreateTextNode(title)); toastNodeList.Item(1).AppendChild(toastDoc.CreateTextNode(content)); ToastNotification toast = new ToastNotification(toastDoc); toast.ExpirationTime = DateTime.Now.AddSeconds(4); }
public async Task parse(string url) { doc = new XmlDocument(); string xml = await getXML(url); xmlStr = xml.Replace("itunes:", "itunes-"); doc.LoadXml(xmlStr); itemCount = doc.GetElementsByTagName("item").Count; foreach (XmlElement elem in doc.GetElementsByTagName("item")) { Episodes.Add(new Episode { title = getNodeValue(elem, "title"), description = getNodeValue(elem, "description"), summary = getNodeValue(elem, "itunes-summary"), duration = getNodeValue(elem, "itunes-duration"), url = getNodeAttribute(elem, "enclosure", "url"), length = getNodeAttribute(elem, "enclosure", "length"), type = getNodeAttribute(elem, "enclosure", "type"), pubDate = getNodeValue(elem, "pubDate"), isExplicit = getNodeValue(elem, "itunes-explicit"), isPermalink = getNodeAttribute(elem, "guid", "isPermaLink"), author = getNodeValue(elem, "itunes-author"), } ); } //foreach (Episode e in _episodes) //{ // Debug.WriteLine(e); //} }
public void Notifica(string mensagem1) { Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText03); // Fill in the text elements Windows.Data.Xml.Dom.XmlNodeList stringElements = toastXml.GetElementsByTagName("text"); stringElements[0].AppendChild(toastXml.CreateTextNode("Beba Água APP")); stringElements[1].AppendChild(toastXml.CreateTextNode(mensagem1)); // Specify the absolute path to an image String imagePath = System.IO.Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location); Windows.Data.Xml.Dom.XmlNodeList imageElements = toastXml.GetElementsByTagName("image"); imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath; // Create the toast and attach event listeners ToastNotification toast = new ToastNotification(toastXml); // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut! ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast); }
private static void UpdateTileImages(XmlDocument tile, IEnumerable<string> images) { var imagesCount = images.Count(); if (imagesCount == 0) return; var imageAttributes = tile.GetElementsByTagName("image"); for (int i = 0; i < imagesCount && i < imageAttributes.Length; i++) { var element = (XmlElement)imageAttributes[i]; var source = "ms-resource:" + images.ElementAt(i); element.SetAttribute("src", source); } }
async Task<List<string>> getFavorites() { StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\data\Favorites.xml"); string xmlString = await FileIO.ReadTextAsync(file); XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlString); List<string> _podcasts = new List<string>(); XmlNodeList channels = doc.GetElementsByTagName("url"); int itemCount = channels.Count; foreach (XmlElement elem in channels) { if (!String.IsNullOrWhiteSpace(elem.InnerText)) _podcasts.Add(elem.InnerText); } return _podcasts; }
private void load() { string titleString = File.ReadAllText("title.xml"); Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(titleString); Windows.Data.Xml.Dom.XmlNodeList titles = doc.GetElementsByTagName("text"); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); for (int i = 0; i < ViewModel.AllItems.Count; i++) { titles[0].InnerText = titles[2].InnerText = titles[4].InnerText = ViewModel.AllItems[i].title; titles[1].InnerText = titles[3].InnerText = titles[5].InnerText = ViewModel.AllItems[i].description; var tileNotification = new TileNotification(doc); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(tileNotification); } }
private static void AppendTextElementsToNotification(ToastContent toastContent, XmlDocument xml) { var elements = xml.GetElementsByTagName(TextNode); var hasTitleOrContentElement = elements.Count == 1; var hasTitleAndContentElement = elements.Count == 2; var hasTitleContentAndSecondContentElement = elements.Count == 3; if (hasTitleOrContentElement || hasTitleAndContentElement) elements[0].InnerText = toastContent.Title ?? toastContent.Content ?? string.Empty; if (hasTitleAndContentElement) elements[0].InnerText = toastContent.Content ?? string.Empty; if (hasTitleContentAndSecondContentElement) elements[0].InnerText = toastContent.SecondContent ?? string.Empty; }
public void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine("Background task starting"); tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text04); tileText = tileXml.GetElementsByTagName("text")[0] as XmlElement; buses = new Bus[] { new Bus("99", 3), new Bus("88", 7), new Bus("6", 16), new Bus("47", 21), }; new Timer(onTimer, new object(), 0, 1000); }
public static void Show(string header, string text) { XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); //Fill in the text elements XmlNodeList stringElements = toastXml.GetElementsByTagName("text"); stringElements[0].AppendChild(toastXml.CreateTextNode(header)); stringElements[1].AppendChild(toastXml.CreateTextNode(text)); // Create the toast and attach event listeners ToastNotification toast = new ToastNotification(toastXml); // Show the toast. Be sure to specify the AppUserModelId on your application's shortcut! ToastNotificationManager.CreateToastNotifier("ELO").Show(toast); }
//磁铁创建函数 private void tileCreate() { Windows.Data.Xml.Dom.XmlDocument document = new Windows.Data.Xml.Dom.XmlDocument(); document.LoadXml(System.IO.File.ReadAllText("XMLFile1.xml")); Windows.Data.Xml.Dom.XmlNodeList Texttitle = document.GetElementsByTagName("text"); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); for (int i = 0; i < ViewModel.AllRecords.Count; i++) { if (i < 5) { Texttitle[0].InnerText = Texttitle[2].InnerText = Texttitle[4].InnerText = ViewModel.AllRecords[i].score.ToString(); Texttitle[1].InnerText = Texttitle[3].InnerText = Texttitle[5].InnerText = ViewModel.AllRecords[i].date.ToString(); TileNotification newTile = new TileNotification(document); TileUpdateManager.CreateTileUpdaterForApplication().Update(newTile); } } }
public void tile() { Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument(); xdoc.LoadXml(File.ReadAllText("tile.xml")); Windows.Data.Xml.Dom.XmlNodeList tilelist = xdoc.GetElementsByTagName("text"); tilelist[0].InnerText = title.Text; tilelist[2].InnerText = title.Text; tilelist[4].InnerText = title.Text; tilelist[1].InnerText = describe.Text; tilelist[3].InnerText = describe.Text; tilelist[5].InnerText = describe.Text; tilelist[6].InnerText = title.Text; tilelist[7].InnerText = describe.Text; TileNotification notification = new TileNotification(xdoc); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(notification); }
private void ContentGet(string content) { try { XmlDocument tileXml = new XmlDocument(); tileXml.LoadXml(content); XmlNodeList images = tileXml.GetElementsByTagName("image"); if (images.Count>0) { foreach (XmlElement item in images) { string imgSource = item.GetAttributeNode("src").Value.ToString(); ImagePush.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(this.BaseUri, imgSource)); } } String texts = tileXml.InnerText; Text1Text.Text = texts; XmlNodeList badges = tileXml.ChildNodes; if (badges.Count>0) { foreach (XmlElement item in badges) { string badgeContent = item.GetAttributeNode("value").Value.ToString(); Text1Text.Text += "badge: " + badgeContent; } } } catch { Text1Text.Text = "can't display push content"; } }
private async Task UpdateLiveTile() { var mapRotation = await SplatoonInk.GetMapRotation(); string xml = "<tile>\n"; xml += "<visual version=\"2\">\n"; xml += " <binding template=\"TileSquare150x150Text02\" fallback=\"TileSquareText02\">\n"; xml += " <text id=\"1\">Row 0</text>\n"; xml += " <text id=\"2\">Row 1</text>\n"; xml += " </binding>\n"; xml += " <binding template=\"TileWide310x150Text01\" fallback=\"TileWideText01\">\n"; xml += " <text id=\"1\">Text Field 1 (larger text)</text>\n"; xml += " <text id=\"2\">Wide Row 0</text>\n"; xml += " <text id=\"3\">Wide Row 1</text>\n"; xml += " <text id=\"4\">Wide Row 2</text>\n"; xml += " <text id=\"5\">Wide Row 3</text>\n"; xml += " </binding>\n"; xml += "</visual>\n"; xml += "</tile>"; XmlDocument txml = new XmlDocument(); txml.LoadXml(xml); var tileText = txml.GetElementsByTagName("text"); (tileText[0] as XmlElement).InnerText = string.Format("{0}", mapRotation.schedule[0].startAndEndTimeString); var map1 = string.Format("{0}: {1}", resourceLoader.GetString("RegularBattle"), mapRotation.schedule[0].regular.maps[0].shortName); var map2 = string.Format("{0}: {1}", resourceLoader.GetString("RegularBattle"), mapRotation.schedule[0].regular.maps[1].shortName); var map3 = string.Format("{0}: {1}", mapRotation.schedule[0].ranked.rules, mapRotation.schedule[0].ranked.maps[0].shortName); var map4 = string.Format("{0}: {1}", mapRotation.schedule[0].ranked.rules, mapRotation.schedule[0].ranked.maps[1].shortName); (tileText[1] as XmlElement).InnerText = string.Format("{0}\r\n{1}\r\n{2}\r\n{3}", map1, map2, map3, map4); (tileText[2] as XmlElement).InnerText = string.Format("Map Rotation - {0}", mapRotation.schedule[0].startAndEndTimeString); (tileText[3] as XmlElement).InnerText = string.Format("{0}: {1}", resourceLoader.GetString("RegularBattle"), mapRotation.schedule[0].regular.maps[0].name); (tileText[4] as XmlElement).InnerText = string.Format("{0}: {1}", resourceLoader.GetString("RegularBattle"), mapRotation.schedule[0].regular.maps[1].name); (tileText[5] as XmlElement).InnerText = string.Format("{0}: {1}", mapRotation.schedule[0].ranked.rules, mapRotation.schedule[0].ranked.maps[0].name); (tileText[6] as XmlElement).InnerText = string.Format("{0}: {1}", mapRotation.schedule[0].ranked.rules, mapRotation.schedule[0].ranked.maps[1].name); var tileNotification = new TileNotification(txml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public static void FromHtml(RichTextBlock rtb, string html) { var oldHtml = html; html = System.Net.WebUtility.HtmlDecode(html); html = html.Replace("•", "<br /> - "); html = html.Replace("·", "<br /> - "); html = html.Replace("<li>", " - ").Replace("</li>", "<br />").Replace("<ul>","<p>").Replace("</ul>","</p>"); html = html.Replace("<br /><br /><p>", "<br /><p>"); html = $"<html><body><p>{html}</p></body></html>"; var v = new XmlConvert(); var htmlFromDoc = v.Convert(html); htmlFromDoc = htmlFromDoc.Replace("<p />", ""); XmlDocument document = new XmlDocument(); document.LoadXml(htmlFromDoc); XmlElement elem = (XmlElement)(document.GetElementsByTagName("body")[0]); var container = new RichTextBlockTextContainer(rtb); ParseElement(elem, container); }
private void login_processing(string data) { try { account = new Account(); XmlDocument doc = new XmlDocument(); doc.LoadXml(data); XmlNodeList list = doc.GetElementsByTagName("response"); for (int i = 0; i < list.Count; i++) { account.sid = doc.GetElementsByTagName("sid")[i].InnerText; account.sid_name = doc.GetElementsByTagName("sid_name")[i].InnerText; DateTime t = ConvertFromUnixTimestamp(Convert.ToDouble(doc.GetElementsByTagName("servertime")[i].InnerText)); DateTime d = new DateTime(); d = DateTime.Now; time = Math.Round((d - t).TotalHours); } XmlNodeList alist = doc.GetElementsByTagName("account"); for (int i = 0; i < alist.Count; i++) { account.login = doc.GetElementsByTagName("login")[i].InnerText; account.balance = doc.GetElementsByTagName("balance")[i].InnerText; } List<Service> ls = new List<Service>(); XmlNodeList ilist = doc.GetElementsByTagName("item"); for (int i = 0; i < ilist.Count; i++) { try { Service s = new Service(); s.id = doc.GetElementsByTagName("id")[i].InnerText; s.type = doc.GetElementsByTagName("type")[i].InnerText; s.name = doc.GetElementsByTagName("name")[i].InnerText; s.expire = doc.GetElementsByTagName("expire")[i].InnerText; ls.Add(s); } catch (Exception) { } } account.services = ls; } catch (Exception ex) { throw new System.InvalidOperationException("Login processing error"); } }
private void SendButton_Click(object sender, RoutedEventArgs e) { var xmlFile = XElement.Load("Tile.xml"); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(xmlFile.ToString()); // Change content of tile foreach (IXmlNode node in xmldoc.GetElementsByTagName("text")) { if (node.ParentNode.Attributes.GetNamedItem("template").InnerText == "TileWide310x150ImageAndText01") { if (node.Attributes.GetNamedItem("id").InnerText == "1") { node.InnerText = this.text1TextBox.Text; } } else if (node.ParentNode.Attributes.GetNamedItem("template").InnerText == "TileSquare150x150Text02") { if (node.Attributes.GetNamedItem("id").InnerText == "1") { node.InnerText = this.text1TextBox.Text; } if (node.Attributes.GetNamedItem("id").InnerText == "2") { node.InnerText = this.text2TextBox.Text; } } } TileNotification tileNotification = new TileNotification(xmldoc); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); Application.Current.Exit(); }
private async void buyMag_Click(object sender, RoutedEventArgs e) { if (licenseInformation == null) return; if (!licenseInformation.ProductLicenses[product_id].IsActive) { try { // The customer doesn't own this feature, so // show the purchase dialog. var receipt = await CurrentAppSimulator.RequestProductPurchaseAsync(product_id, true); if (!licenseInformation.ProductLicenses[product_id].IsActive || receipt == "") return; await DownloadManager.StoreReceiptAsync(product_id, receipt); // the in-app purchase was successful // TEST ONLY // ================================================= var f = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\test\receipt.pmd"); var xml = new XmlDocument(); xml = await XmlDocument.LoadFromFileAsync(f); var item = xml.GetElementsByTagName("ProductReceipt")[0] as XmlElement; item.SetAttribute("ProductId", product_id); var date = new DateTimeOffset(DateTime.Now); date = date.AddMinutes(3); var str = date.ToString("u"); str = str.Replace(" ", "T"); item.SetAttribute("ExpirationDate", str); receipt = xml.GetXml(); if (DownloadManager.ReceiptExpired(receipt)) return; // ================================================= buyMag.Visibility = Windows.UI.Xaml.Visibility.Collapsed; if (Bought != null) { Bought(this, DownloadManager.GetUrl(product_id, receipt, relativePath)); this.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } else { var messageDialog = new MessageDialog("Purchase successfull"); var task = messageDialog.ShowAsync().AsTask(); } } catch (Exception) { // The in-app purchase was not completed because // an error occurred. var messageDialog = new MessageDialog("Unexpected error"); var task = messageDialog.ShowAsync().AsTask(); } } else { var messageDialog = new MessageDialog("You already purchased this app"); var task = messageDialog.ShowAsync().AsTask(); } }
static List<SvgTest> ExtractTestsFromIndex(XmlDocument doc) { List<SvgTest> tests = new List<SvgTest>(); var links = doc.GetElementsByTagName("a"); foreach (var link in links) { var svgName = link.InnerText; var newTest = new SvgTest(svgName); // We don't expect anything in these chapters to work if (newTest.Chapter == "animate" || newTest.Chapter=="interact" || newTest.Chapter=="script") continue; // Filter out any tests that end with 'z' since we don't support // compressed files yet. // TODO; support svgz files if (newTest.SvgUri.EndsWith("svgz")) continue; // Filter out any DOM tests; we don't support the DOM if (newTest.Name.Contains("-dom")) continue; tests.Add(newTest); } return tests; }
public async Task getBookContent(Book book) { try { BookChapters.Chapters.Clear(); Dictionary <String, String> ncxDict = await parseNcx(book); Dictionary <String, String> refDict = await getReferences(book); Dictionary <String, String> itemDict = await getItems(book); String currentBookFolder = book.Location; Windows.Data.Xml.Dom.XmlDocument doc = await Routines.GetFile(book.Location + "\\META-INF", "container.xml"); var opfPathinit = doc.GetElementsByTagName("rootfile").Item(0).Attributes.GetNamedItem("full-path").NodeValue; String[] opfPath_tmp = Routines.parseString(opfPathinit.ToString()); String opfPath = opfPath_tmp[0]; String opfFile = opfPath_tmp[1]; currentBookFolder = currentBookFolder + "/" + opfPath; doc = await Routines.GetFile(currentBookFolder, opfFile); var itemrefcount = doc.GetElementsByTagName("itemref").Count; int chapNameCount = 0; for (uint index = 0; index < itemrefcount; index++) { //this.updatenotifier.Text = "Getting chapter " + index + " of " + itemrefcount + " ...."; var itemref = doc.GetElementsByTagName("itemref").Item(index).Attributes.GetNamedItem("idref").NodeValue; try { //if (mediaType.ToString().Equals("application/xhtml+xml") && id.ToString().Equals(itemref.ToString())) //{ //var chapPath = doc.GetElementsByTagName("item").Item(index).Attributes.GetNamedItem("href").NodeValue; var chapPath = itemDict[itemref.ToString().ToLower()]; String[] filesPath = Routines.parseString(chapPath.ToString()); String chapContent = ""; if (chapContent == null || chapContent.Trim(' ') == " ") { continue; } chapNameCount++; String chapName = "Chapter " + chapNameCount; if (ncxDict.ContainsKey(itemref.ToString())) { chapName = ncxDict[itemref.ToString()]; } else if (refDict.ContainsKey(itemref.ToString())) { if (ncxDict.ContainsKey(refDict[itemref.ToString()])) { chapName = ncxDict[refDict[itemref.ToString()]]; } else { chapName = "Chapter " + chapNameCount; } } else { chapName = "Chapter " + chapNameCount; } chapContent = chapContent.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine); BookChapters.Chapters.Add(new BookChapter(chapNameCount.ToString(), chapName.ToString().ToUpper(), (currentBookFolder + filesPath[0]), filesPath[1])); //break; //} //} } catch { } } } catch { //Routines.DisplayMsg("Epub files incorrectly formatted"); } }
private static void SetTileTexts(XmlDocument xmlDocument, params string[] texts) { if (texts != null) { try { var textElements = xmlDocument.GetElementsByTagName("text").ToArray(); for (int n = 0; n < texts.Length; n++) { var textElement = textElements[n] as XmlElement; textElement.InnerText = texts[n]; } } catch (Exception ex) { Debug.WriteLine(ex); } } }
/// <summary> /// The entry point of a background task. /// </summary> /// <param name="taskInstance">The current background task instance.</param> public void Run(IBackgroundTaskInstance taskInstance) { backgroundTaskInstance = taskInstance; var details = taskInstance.TriggerDetails as BluetoothLEAdvertisementWatcherTriggerDetails; if (details != null) { // If the background watcher stopped unexpectedly, an error will be available here. var error = details.Error; // The Advertisements property is a list of all advertisement events received // since the last task triggered. The list of advertisements here might be valid even if // the Error status is not Success since advertisements are stored until this task is triggered IReadOnlyList <BluetoothLEAdvertisementReceivedEventArgs> advertisements = details.Advertisements; // The signal strength filter configuration of the trigger is returned such that further // processing can be performed here using these values if necessary. They are read-only here. var rssiFilter = details.SignalStrengthFilter; // Advertisements can contain multiple events that were aggregated, each represented by // a BluetoothLEAdvertisementReceivedEventArgs object. List <iBeaconData> beacons = new List <iBeaconData>(); foreach (var adv in advertisements) { var beacon = adv.Advertisement.iBeaconParseAdvertisement(adv.RawSignalStrengthInDBm); if (beacon != null) { beacons.Add(beacon); } } var serializer = new DataContractJsonSerializer(typeof(List <iBeaconData>)); string content = string.Empty; using (MemoryStream stream = new MemoryStream()) { serializer.WriteObject(stream, beacons); stream.Position = 0; content = new StreamReader(stream).ReadToEnd(); } // Store the message in a local settings indexed by this task's name so that the foreground App // can display this message. ApplicationData.Current.LocalSettings.Values[taskInstance.Task.Name] = content; ApplicationData.Current.LocalSettings.Values[taskInstance.Task.Name + "TimeStamp"] = DateTime.Now.ToBinary(); //Warning each 5 minutes to uninstall task if not debugging anymore if (!ApplicationData.Current.LocalSettings.Values.ContainsKey(taskInstance.Task.Name + "DebugWarning")) { ApplicationData.Current.LocalSettings.Values.Add(taskInstance.Task.Name + "DebugWarning", DateTime.Now.ToBinary()); } else { if ((DateTime.Now - DateTime.FromBinary((long)ApplicationData.Current.LocalSettings.Values[taskInstance.Task.Name + "DebugWarning"])).TotalMinutes >= 5) { ApplicationData.Current.LocalSettings.Values[taskInstance.Task.Name + "DebugWarning"] = DateTime.Now.ToBinary(); Windows.Data.Xml.Dom.XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); Windows.Data.Xml.Dom.XmlNodeList elements = toastXml.GetElementsByTagName("text"); foreach (IXmlNode node in elements) { node.InnerText = taskInstance.Task.Name + " remember to uninstall task if not debugging"; } ToastNotification notification = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(notification); } } } }
async Task ParseAsync(Windows.Data.Xml.Dom.XmlDocument document, bool notify, bool checkDownloads) { try { GetLocalImage(); var channel = document.GetElementsByTagName("channel")[0]; var tempList = new List <Episode>(); foreach (var currentItem in channel.ChildNodes) { if (currentItem.NodeName != "item") { continue; } var item = currentItem as Windows.Data.Xml.Dom.XmlElement; var episode = new Episode { Link = item.GetChildNodeTextValue("link", ""), Title = item.GetChildNodeTextValue("title", "").Sanitize(), Subtitle = item.GetChildNodeTextValue("itunes:subtitle", "").Sanitize(), Author = item.GetChildNodeTextValue("itunes:author", "").Sanitize(), Summary = item.GetChildNodeTextValue("description", "").SanitizeAsHTML(), Enclosure = item.GetChildNodeAttribute("enclosure", "url", ""), PictureUrl = item.GetChildNodeAttribute("itunes:image", "href", ""), DeclaredDuration = item.GetChildNodeTextValue("itunes:duration", ""), Keywords = item.GetChildNodeTextValue("itunes:keywords", ""), PublicationDate = item.GetChildNodeTextValue("pubDate", "").TryParseAsDateTime(), PodcastFeedUrl = FeedUrl }; var length = item.GetChildNodeAttribute("enclosure", "length", ""); double estimatedLength; if (Double.TryParse(length, out estimatedLength)) { episode.EstimatedFileSize = estimatedLength; } if (!episode.DeclaredDuration.Contains(":")) { episode.DeclaredDuration = ""; } var itunesSummary = item.GetChildNodeTextValue("itunes:summary", "").SanitizeAsHTML(); if (itunesSummary.Length > episode.Summary.Length) { episode.Summary = itunesSummary; } var contentSummary = item.GetChildNodeTextValue("content:encoded", "").SanitizeAsHTML(); if (contentSummary.Length > episode.Summary.Length) { episode.Summary = contentSummary; } if (string.IsNullOrEmpty(episode.Author)) { episode.Author = Title; } if (string.IsNullOrEmpty(episode.Enclosure)) { episode.Enclosure = episode.Link; } if (string.IsNullOrEmpty(episode.PictureUrl)) { episode.PictureUrl = LocalImage; } episode.Clean(); tempList.Add(episode); } var addedEpisodes = new List <Episode>(); var indexToInject = 0; foreach (var episode in tempList.OrderByDescending(e => e.PublicationDate)) { var inLibraryEpisode = Episodes.FirstOrDefault(e => e.Enclosure == episode.Enclosure); if (inLibraryEpisode != null) { inLibraryEpisode.Author = episode.Author; inLibraryEpisode.DeclaredDuration = episode.DeclaredDuration; inLibraryEpisode.Keywords = episode.Keywords; inLibraryEpisode.Link = episode.Link; inLibraryEpisode.PictureUrl = episode.PictureUrl; inLibraryEpisode.PodcastFeedUrl = episode.PodcastFeedUrl; inLibraryEpisode.Title = episode.Title; inLibraryEpisode.Subtitle = episode.Subtitle; inLibraryEpisode.Summary = episode.Summary; inLibraryEpisode.PublicationDate = episode.PublicationDate; inLibraryEpisode.EstimatedFileSize = episode.EstimatedFileSize; continue; } await DispatchManager.RunOnDispatcherAsync(() => { Episodes.Insert(indexToInject, episode); }); indexToInject++; addedEpisodes.Add(episode); if (notify && IsInLibrary && LocalSettings.Instance.Notifications) { Messenger.Notify(string.Format(LocalSettings.Instance.NotificationMessage, episode.Title), Title, "", LocalImage); } } if (addedEpisodes.Count > 0 && IsInLibrary && AppSettings.Instance.AutomaticallyAddNewEpisodeToPlaylist) { await DispatchManager.RunOnDispatcherAsync(() => { var reversedAddedEpisodes = addedEpisodes.OrderBy(e => e.PublicationDate).ToList(); if (Playlist.CurrentPlaylist != null) { Playlist.CurrentPlaylist.AddEpisodes(reversedAddedEpisodes); } else { Playlist.EpisodesToAdd.AddRange(reversedAddedEpisodes); } }); } LocalSettings.Instance.NewEpisodesCount += addedEpisodes.Count; if (checkDownloads) { CheckForAutomaticDownloads(); } if (toExecuteWhenReady != null) { toExecuteWhenReady(); toExecuteWhenReady = null; } } catch { await Messenger.ErrorAsync(StringsHelper.Error_UnableToParseRSS + " (" + Title + ")"); } }
private static void SetSilent(bool useSound, XmlDocument toastXml) { var audio = toastXml.GetElementsByTagName("audio").FirstOrDefault(); if (audio == null) { audio = toastXml.CreateElement("audio"); var toastNode = ((XmlElement)toastXml.SelectSingleNode("/toast")); if (toastNode != null) { toastNode.AppendChild(audio); } } var attribute = toastXml.CreateAttribute("silent"); attribute.Value = (!useSound).ToString().ToLower(); audio.Attributes.SetNamedItem(attribute); }
private async void SaveAsync(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (Validate()) { if (comp != null) { comp.Naam = Naam.Text; comp.Openingsuur = Openingsuur.Text; comp.Sluituur = Sluitsuur.Text; comp.Categorie = await categorieViewModel.getCategorie(Categorie.SelectedValue.ToString()); comp.Gemeente = Gemeente.Text; comp.Straat = Straat.Text; comp.Land = Land.Text; comp.Website = Website.Text; comp.Telefooonnummer = Telefoonnummer.Text; comp.Information = Beschrijving.Text; var ondernemingAnswer = await ondernemingenViewModel.bewerkOnderneming(comp); if (ondernemingAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Onderneming")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(comp.Naam + " werd aangepast")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } else { var categorie = await categorieViewModel.getCategorie(Categorie.SelectedValue.ToString()); Onderneming onderneming = new Onderneming( Naam.Text, Openingsuur.Text, Sluitsuur.Text, categorie.Id, Gemeente.Text, Straat.Text, Land.Text, Website.Text, Telefoonnummer.Text, Beschrijving.Text, ((App)Application.Current).gebruiker.Id ); var ondernemingAnswer = await ondernemingenViewModel.addOnderneming(onderneming); if (ondernemingAnswer) { this.Frame.Navigate(typeof(BeheerOndernemenPage_Mobile)); ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); XmlNodeList toastTekstElementen = toastXml.GetElementsByTagName("text"); toastTekstElementen[0].AppendChild(toastXml.CreateTextNode("Onderneming")); toastTekstElementen[1].AppendChild(toastXml.CreateTextNode(onderneming.Naam + " werd toegevoegd aan je ondernemingen")); IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("duration", "long"); ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); } } } }
static private void SetTileTexts(XmlDocument xmlDocument, params string[] texts) { if (texts != null) { try { var textElements = xmlDocument.GetElementsByTagName("text").ToArray(); for (int n = 0; n < texts.Length; n++) { var textElement = textElements[n] as XmlElement; textElement.InnerText = texts[n]; } } catch (Exception ex) { AppLogs.WriteError("TileServices.SetTileTexts", ex); } } }
public IAsyncOperation<IList<ItemKey>> NewRawAsync(string xml) { // For new items there should not be any item keys, // created, or updated dates because these will be new items var loadSettings = new XmlLoadSettings {ProhibitDtd = true}; var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml, loadSettings); // Do not convert these to a foreach loop since the collection // is modified by the remove XmlNodeList nodes = xmlDoc.GetElementsByTagName("thing-id"); for (int i = (int) nodes.Length - 1; i >= 0; i--) { IXmlNode node = nodes[i]; node.ParentNode.RemoveChild(node); } nodes = xmlDoc.GetElementsByTagName("updated"); for (int i = (int) nodes.Length - 1; i >= 0; i--) { IXmlNode node = nodes[i]; node.ParentNode.RemoveChild(node); } nodes = xmlDoc.GetElementsByTagName("created"); for (int i = (int) nodes.Length - 1; i >= 0; i--) { IXmlNode node = nodes[i]; node.ParentNode.RemoveChild(node); } // Our put things xml does not support <things> or <ArrayOfThings> // We just want to serialize <thing> repeatedly nodes = xmlDoc.GetElementsByTagName("thing"); var parsedXml = new StringBuilder(); for (int i = 0; i < nodes.Length; i++) { parsedXml.Append(nodes[i].GetXml()); } return PutRawAsync(parsedXml.ToString()); }
private async void GetCurrentSong(string url) { try { // WP cashes responses with same url string newUrl = url + "?temp=" + DateTime.Now.Millisecond; string page = await new HttpClient().GetStringAsync(newUrl); string artist = "", song = ""; if (_csUrl.Equals("http://aristocrats.fm/service/NowOnAir.xml")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(page); var nodes = xmlDoc.GetElementsByTagName("Artist"); artist = nodes[0].Attributes.GetNamedItem("name").InnerText; nodes = xmlDoc.GetElementsByTagName("Song"); song = nodes[0].Attributes.GetNamedItem("title").InnerText; if (artist == "" && song == "") { song = "Прямой эфир"; artist = "Радио Аристократы"; } } else { page = page.Replace("h4", ""); page = page.Replace("h5", ""); page = page.Replace("/", ""); string[] separators = { "<>" }; string[] CurrentSong = page.Split(separators, StringSplitOptions.RemoveEmptyEntries); song = CurrentSong[0]; if (CurrentSong.Length > 1) { artist = CurrentSong[1]; } else { artist = ""; } } Artist.Text = artist; Song.Text = song; } catch (Exception) { Artist.Text = ""; Song.Text = ""; } }
private async Task GenerateSuggestions(StorageFile file, SearchSuggestionCollection suggestions) { XmlDocument doc = new XmlDocument(); doc.LoadXml(await FileIO.ReadTextAsync(file)); XmlNodeList nodes = doc.GetElementsByTagName("Section"); if (nodes.Count > 0) { IXmlNode section = nodes[0]; foreach (IXmlNode node in section.ChildNodes) { if (node.NodeType != NodeType.ElementNode) { continue; } if (node.NodeName.Equals("Separator", StringComparison.CurrentCultureIgnoreCase)) { string title = node.Attributes.GetNamedItem("title").NodeValue.ToString(); if (string.IsNullOrWhiteSpace(title)) { suggestions.AppendSearchSeparator(title); } } else { AddSuggestionFromNode(node, suggestions); } } } }
public override TileNotification GetNotificacion() { tile = new XmlDocument(); tile.LoadXml(stile); var nodeImage = tile.GetElementsByTagName("image"); ((Windows.Data.Xml.Dom.XmlElement)nodeImage[0]).SetAttribute("src", SmallBackgroundImage.OriginalString); ((Windows.Data.Xml.Dom.XmlElement)nodeImage[1]).SetAttribute("src", SmallBackgroundImage.OriginalString); ((Windows.Data.Xml.Dom.XmlElement)nodeImage[2]).SetAttribute("src", BackgroundImage.OriginalString); ((Windows.Data.Xml.Dom.XmlElement)nodeImage[3]).SetAttribute("src", WideBackgroundImage.OriginalString); var nodeText = tile.GetElementsByTagName("text"); nodeText[0].InnerText = Title.ToString()?? "Title"; nodeText[1].InnerText = BackContent.ToString()?? ""; nodeText[2].InnerText = BackTitle.ToString()??""; nodeText[3].InnerText = WideBackContent.ToString()??""; //this.tile.GetXml(); var tileNotc = new TileNotification(this.tile); //tileNotc.Tag = NavigationUri != null ? NavigationUri.OriginalString.ToString() :tileNotc.Tag; return tileNotc; }