本文整理匯總了C#中Windows.Data.Xml.Dom.XmlDocument.GetElementsByTagName方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.GetElementsByTagName方法的具體用法?C# XmlDocument.GetElementsByTagName怎麽用?C# XmlDocument.GetElementsByTagName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Windows.Data.Xml.Dom.XmlDocument
的用法示例。
在下文中一共展示了XmlDocument.GetElementsByTagName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetNotificacion
public override TileNotification GetNotificacion()
{
tile = new XmlDocument();
tile.LoadXml(stile);
//System.Diagnostics.Debug.Write(tile.GetXml());
var nodevisual = tile.GetElementsByTagName("binding");
if (Title != null && Title != "")
{
((XmlElement)nodevisual[1]).SetAttribute("displayName", this.Title);
}
var nodeImage = tile.GetElementsByTagName("image");
((Windows.Data.Xml.Dom.XmlElement)nodeImage[0]).SetAttribute("src", BackgroundImage.OriginalString);
((Windows.Data.Xml.Dom.XmlElement)nodeImage[1]).SetAttribute("src", BackgroundImage.OriginalString);
//((Windows.Data.Xml.Dom.XmlElement)nodeImage[2]).SetAttribute("src", BackgroundImage.OriginalString);
var nodeText = tile.GetElementsByTagName("text");
nodeText[0].InnerText = BackTitle.ToString();
nodeText[1].InnerText = BackContent.ToString();
//nodeText[2].InnerText = BackContent.ToString();
//System.Diagnostics.Debug.Write(this.tile.GetXml());
var tileNotc = new TileNotification(this.tile);
return tileNotc;
}
示例2: SetTileImages
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);
}
}
}
示例3: 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);
}
示例4: ToastText
public ToastText(string message, ToastTemplateType type)
{
xmlDoc = ToastNotificationManager.GetTemplateContent(type);
var textTag = xmlDoc.GetElementsByTagName("text").First();
textTag.AppendChild(xmlDoc.CreateTextNode(message));
}
示例5: RefreshClubMembers
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;
}
示例6: AppendImageToNotification
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);
}
示例7: WriteAutoCommandsToHandler
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));
}
}
示例8: OnHtmlChanged
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));
}
示例9: ParseChapter
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;
}
示例10: ConvertHtmlToRtf
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;
}
示例11: listApps
/*
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)
{ }
}
示例12: parse
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);
//}
}
示例13: UpdateTileImages
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);
}
}
示例14: getFavorites
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;
}
示例15: Run
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);
}