本文整理匯總了C#中Windows.Data.Xml.Dom.XmlDocument.SelectSingleNode方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.SelectSingleNode方法的具體用法?C# XmlDocument.SelectSingleNode怎麽用?C# XmlDocument.SelectSingleNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.Data.Xml.Dom.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.SelectSingleNode方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例2: 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);
}
示例3: 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;
}
示例4: Load
public void Load()
{
this.Conference = new Conference();
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(xml);
IXmlNode nodeSchedule = xDoc.SelectSingleNode("schedule");
IXmlNode nodeConference = nodeSchedule.SelectSingleNode("conference");
LoadConferenceData(nodeConference);
XmlNodeList nodesDays = nodeSchedule.SelectNodes("day");
foreach (IXmlNode item in nodesDays)
{
LoadConferenceDayData(item);
}
}
示例5: SetSilent
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);
}
示例6: SetToastImage
/*
private void SetToastImage(XmlDocument xml)
{
var nodes = xml.GetElementsByTagName("image");
((XmlElement)nodes[0]).SetAttribute("src", "ms-appx:///Assets/PomodoroTimerLogo.png");
((XmlElement)nodes[0]).SetAttribute("alt", "Pomodoro Timer");
}
*/
private static void SetToastDuration(XmlDocument xml)
{
var node = xml.SelectSingleNode("/toast");
((XmlElement)node).SetAttribute("duration", "long");
}
示例7: GetCity
private async void GetCity(double lat, double lon)
{
HttpClient hc = new HttpClient();
try
{
//string text = await hc.GetStringAsync("http://ditu.google.cn/maps/geo?output=csv&key=abcdef&q=" + lat + "," + lon);
string text = await hc.GetStringAsync("http://maps.googleapis.com/maps/api/geocode/xml?latlng=" + lat + "," + lon + "&sensor=true&language=zh-CN");
XmlDocument doc = new XmlDocument();//創建XML文檔對象
if (!string.IsNullOrEmpty(text))
{
doc.LoadXml(text);//加載xml字符串
//獲取狀態信息
string xpath = @"GeocodeResponse/status";
var node = doc.SelectSingleNode(xpath);
string status = node.InnerText.ToString();
if (status == "OK")
{
//獲取地址信息
xpath = @"GeocodeResponse/result/formatted_address";
node = doc.SelectSingleNode(xpath);
text = node.InnerText.ToString();
text = text.Contains("中國") ? text.Remove(0, 2) : text;
string s1 = "";
decimal d1 = 0.0M;
//if (text.Contains("省"))
//{
// int index = text.IndexOf("省");
// text = text.Substring(index + 1);
//}
foreach (string name in cities.Keys)
{
decimal mm = LevenshteinDistance.Instance.LevenshteinDistancePercent(text, name);
if (mm > d1)
{
s1 = name;
d1 = mm;
}
}
searched.Add(cities[s1]);
cityList.ItemsSource = searched;
tb_locaInfo.Text = "若定位有誤請手動搜索";
pb_loca.Visibility = Visibility.Collapsed;
}
else
{
tb_locaInfo.Text = "位置獲取失敗,請手動搜索";
pb_loca.Visibility = Visibility.Collapsed;
}
}
else
{
tb_locaInfo.Text = "位置獲取失敗,請手動搜索";
pb_loca.Visibility = Visibility.Collapsed;
}
//text = text.Substring(text.IndexOf('"') + 1);
//text = text.Substring(0, text.IndexOf('"'));
}
catch (Exception)
{
tb_locaInfo.Text = "位置獲取失敗,請手動搜索";
pb_loca.Visibility = Visibility.Collapsed;
}
}
示例8: PodcastFeed
public PodcastFeed(XmlDocument dom) : base(dom.SelectSingleNode("/rss/channel"))
{
Document = dom;
}
示例9: CallRpc
public async Task<XmlRpcResponse> CallRpc(string methodName, List<XmlRpcValue> parameters) {
var sb = new StringBuilder();
var writer = XmlWriter.Create(sb);
writer.WriteStartDocument();
writer.WriteStartElement("methodCall");
writer.WriteElementString("methodName", methodName);
if (parameters != null && parameters.Count() > 0)
{
writer.WriteStartElement("params");
foreach (var parm in parameters)
{
writer.WriteStartElement("param");
writer.WriteStartElement("value");
parm.BuildXml(writer);
writer.WriteEndElement();
writer.WriteEndElement();
}
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Dispose();
try
{
var client = new HttpClient();
if (Useragent != null)
{
client.DefaultRequestHeaders.UserAgent.Add(new Windows.Web.Http.Headers.HttpProductInfoHeaderValue(Useragent));
}
var inputPars = sb.ToString();
var result = await client.PostAsync(_uri, new HttpStringContent(inputPars, Windows.Storage.Streams.UnicodeEncoding.Utf8, "text/xml"));
var results = await result.Content.ReadAsStringAsync();
result.EnsureSuccessStatusCode();
result.Dispose();
client.Dispose();
sb.Clear();
var resultDoc = new Windows.Data.Xml.Dom.XmlDocument();
var settings = new XmlLoadSettings()
{
ElementContentWhiteSpace = false
};
resultDoc.LoadXml(results.Trim(), settings);
var node = resultDoc.SelectSingleNode("methodResponse");
if (node != null)
{
var ret = new XmlRpcResponse(node);
return ret;
}
throw new XmlRpcException(801, "Response failed to return proper XML response");
}
catch (Exception ex)
{
if (ex is XmlRpcException)
{
throw ex;
}
else
{
throw new XmlRpcException(800, ex.Message);
}
}
return null;
}
示例10: IconicTile_Toggled
private async void IconicTile_Toggled(object sender, RoutedEventArgs e)
{
if (IconicTile.IsOn)
{
iconicTile = new SecondaryTile(
"IconicTile",
"Iconic",
"Arguments",
new Uri("ms-appx:///Assets/yellow.150x150.png", UriKind.Absolute),
TileSize.Square150x150);
await iconicTile.RequestCreateAsync();
tileXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
tileImage.SetAttribute("value", "31");
BadgeNotification badgeNotification = new BadgeNotification(tileXml);
BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(iconicTile.TileId).Update(badgeNotification);
tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150IconWithBadge);
tileImage = tileXml.GetElementsByTagName("image")[0] as XmlElement;
tileImage.SetAttribute("src", "ms-appx:///Assets/icon.130x202.png");
notif = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForSecondaryTile(iconicTile.TileId).Update(notif);
tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150IconWithBadgeAndText);
tileImage = tileXml.GetElementsByTagName("image")[0] as XmlElement;
tileImage.SetAttribute("src", "ms-appx:///Assets/icon.70x110.png");
tileList = tileXml.GetElementsByTagName("text");
(tileList[0] as XmlElement).InnerText = "Header text";
(tileList[1] as XmlElement).InnerText = "First line of text";
(tileList[2] as XmlElement).InnerText = "Second line of text";
notif = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(notif);
}
else
{
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
await iconicTile.RequestDeleteAsync();
}
}
示例11: BadgeToggleSwitch_Toggled
private async void BadgeToggleSwitch_Toggled(object sender, RoutedEventArgs e)
{
if (Badge.IsOn)
{
badgeTile = new SecondaryTile(
"BadgeTile",
"Badge",
"Arguments",
new Uri("ms-appx:///Assets/green.150x150.png", UriKind.Absolute),
TileSize.Square150x150);
await badgeTile.RequestCreateAsync();
tileXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
tileImage.SetAttribute("value", "alert");
BadgeNotification badgeNotification = new BadgeNotification(tileXml);
BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(badgeTile.TileId).Update(badgeNotification);
tileXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
tileImage.SetAttribute("value", "31");
badgeNotification = new BadgeNotification(tileXml);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);
}
else
{
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
await badgeTile.RequestDeleteAsync();
}
}