本文整理汇总了C#中System.Xml.XmlDocument.GetElementsByTagName方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlDocument.GetElementsByTagName方法的具体用法?C# System.Xml.XmlDocument.GetElementsByTagName怎么用?C# System.Xml.XmlDocument.GetElementsByTagName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDocument
的用法示例。
在下文中一共展示了System.Xml.XmlDocument.GetElementsByTagName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameProperties
/// <summary>
/// Setup the game properties
/// </summary>
/// <param name="contentManager">the XNA content manager to be used</param>
/// <param name="graphicDeviceManager">the XNA graphic manager to be used</param>
public GameProperties(Microsoft.Xna.Framework.Content.ContentManager contentManager, Microsoft.Xna.Framework.GraphicsDeviceManager graphicDeviceManager, Microsoft.Xna.Framework.GameWindow window)
{
// load game properties
System.Xml.XmlDocument config = new System.Xml.XmlDocument();
config.Load(@"Content/config.xml");
// try resolution
try
{
graphicDeviceManager.PreferredBackBufferWidth = Convert.ToInt32(config.GetElementsByTagName("resolutionX")[0].InnerText);
graphicDeviceManager.PreferredBackBufferHeight = Convert.ToInt32(config.GetElementsByTagName("resolutionY")[0].InnerText);
Screen screen = Screen.PrimaryScreen;
window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.Width / 2 - graphicDeviceManager.PreferredBackBufferWidth / 2, screen.Bounds.Height / 2 - graphicDeviceManager.PreferredBackBufferHeight / 2);
}
catch (Exception)
{
graphicDeviceManager.PreferredBackBufferWidth = 1280;
graphicDeviceManager.PreferredBackBufferHeight = 720;
}
// try fullscreen
try
{
int fullscreen = Convert.ToInt32(config.GetElementsByTagName("fullscreen")[0].InnerText);
if (fullscreen == 1)
{
Screen screen = Screen.PrimaryScreen;
window.IsBorderless = true;
window.Position = new Microsoft.Xna.Framework.Point(screen.Bounds.X, screen.Bounds.Y);
graphicDeviceManager.PreferredBackBufferWidth = screen.Bounds.Width;
graphicDeviceManager.PreferredBackBufferHeight = screen.Bounds.Height;
this.isFullscreen = true;
}
else
{
this.isFullscreen = false;
}
}
catch (Exception) { }
graphicDeviceManager.ApplyChanges();
// try language settings
try
{
this.SelectedLanguage = config.GetElementsByTagName("language")[0].InnerText;
}
catch(Exception){ }
this.currentGameState = GameState.LoadMenu;
this.input = new InputHandler();
this.contentManager = new Helper.ContentManager(contentManager);
this.spriteBatch = new Microsoft.Xna.Framework.Graphics.SpriteBatch(graphicDeviceManager.GraphicsDevice);
this.graphicDeviceManager = graphicDeviceManager;
this.gameWindow = window;
System.IO.BinaryReader Reader = new System.IO.BinaryReader(System.IO.File.Open(@"Content\Shader\main_shader.mgfxo", System.IO.FileMode.Open));
this.baseShader = new Microsoft.Xna.Framework.Graphics.Effect(this.graphicDeviceManager.GraphicsDevice, Reader.ReadBytes((int)Reader.BaseStream.Length));
}
示例2: Main
static void Main(string[] args)
{
var postdata = "<xml><ToUserName><![CDATA[toUser]]></ToUserName><FromUserName>"+
"<![CDATA[fromUser]]></FromUserName> <CreateTime>1348831860</CreateTime>"+
"<MsgType><![CDATA[text]]></MsgType><Content><![CDATA[Stone]]></Content></xml> ";
if (!string.IsNullOrWhiteSpace(postdata))
{
System.Xml.XmlDocument postObj = new System.Xml.XmlDocument();
postObj.LoadXml(postdata);
var FromUserNameList = postObj.GetElementsByTagName("FromUserName");
string FromUserName = string.Empty;
for (int i = 0; i < FromUserNameList.Count; i++)
{
if (FromUserNameList[i].ChildNodes[0].NodeType == System.Xml.XmlNodeType.CDATA)
{
FromUserName = FromUserNameList[i].ChildNodes[0].Value;
}
}
var toUsernameList = postObj.GetElementsByTagName("ToUserName");
string ToUserName = string.Empty;
for (int i = 0; i < toUsernameList.Count; i++)
{
if (toUsernameList[i].ChildNodes[0].NodeType == System.Xml.XmlNodeType.CDATA)
{
ToUserName = toUsernameList[i].ChildNodes[0].Value;
}
}
var keywordList = postObj.GetElementsByTagName("Content");
string Content = string.Empty;
for (int i = 0; i < keywordList.Count; i++)
{
if (keywordList[i].ChildNodes[0].NodeType == System.Xml.XmlNodeType.CDATA)
{
Content = keywordList[i].ChildNodes[0].Value;
}
}
var time = DateTime.Now;
var textpl = "<xml><ToUserName><![CDATA[" + ToUserName + "]]></ToUserName>" +
"<FromUserName><![CDATA[" + FromUserName + "]]></FromUserName>" +
"<CreateTime>" + time + "</CreateTime><MsgType><![CDATA[text]]></MsgType>" +
"<Content><![CDATA[Welcome to wechat world!"+Content+"]]></Content><FuncFlag>0</FuncFlag></xml> ";
Console.WriteLine(textpl);
}
var codelist = new List<string>() { "faketoken", "bbb", "12345678" };
Console.WriteLine(GetSha1(codelist));
Console.ReadLine();
}
示例3: Load
public void Load()
{
var redirectRuleConfigFile = System.Configuration.ConfigurationManager.AppSettings["RedirectRuleConfigFile"];
if (System.IO.File.Exists(redirectRuleConfigFile))
{
var xmd = new System.Xml.XmlDocument();
xmd.Load(redirectRuleConfigFile);
var nodes = xmd.GetElementsByTagName("RedirectRule");
foreach (System.Xml.XmlElement xme in nodes)
{
var callingClient = IPAddress.Any; //Not yet supported "CallingClient"
var requestHost = xme.Attributes["RequestHost"].Value;
var requestPort = int.Parse(xme.Attributes["RequestPort"].Value);
var targetAddress = xme.Attributes["TargetAddress"].Value;
var targetPort = int.Parse(xme.Attributes["TargetPort"].Value);
Instance.Add(new RedirectRule(callingClient, requestHost, requestPort, IPAddress.Parse(targetAddress), targetPort), false);
}
}
//Append sample redirect rules
//Instance.Add(new RedirectRule(IPAddress.Any, null, 3001, IPAddress.Parse("127.0.0.1"), 3002), false);
//Instance.Add(new RedirectRule(IPAddress.Any, "ws1.test.com", 3003, IPAddress.Parse("127.0.0.1"), 3002), false);
//Save();
}
示例4: Init
public void Init(HttpApplication context)
{
System.Xml.XmlDocument _document = new System.Xml.XmlDocument();
_document.Load(Xy.Tools.IO.File.foundConfigurationFile("App", Xy.AppSetting.FILE_EXT));
foreach (System.Xml.XmlNode _item in _document.GetElementsByTagName("Global")) {
string _className = _item.InnerText;
Type _tempCtonrlType = Type.GetType(_className, false, true);
IGlobal _tempGlobal;
if (_tempCtonrlType == null) {
System.Reflection.Assembly asm = System.Reflection.Assembly.Load(_className.Split(',')[0]);
_tempCtonrlType = asm.GetType(_className.Split(',')[1], false, true);
}
_tempGlobal = System.Activator.CreateInstance(_tempCtonrlType) as IGlobal;
if (_tempGlobal != null) {
global = _tempGlobal;
}
}
if (global == null) { global = new EmptyGlobal(); }
global.ApplicationInit(context);
context.BeginRequest += new EventHandler(context_BeginRequest);
context.Error += new EventHandler(context_Error);
context.EndRequest += new EventHandler(context_EndRequest);
_urlManager = URLManage.URLManager.GetInstance();
}
示例5: loadXml
protected void loadXml()
{
var xml = new System.Xml.XmlDocument();
var fs = new System.IO.FileStream("wardrive.xml", System.IO.FileMode.Open);
xml.Load(fs);
allSamples = new List<Sample>();
WPA2Samples = new List<Sample>();
WEPSamples = new List<Sample>();
WPASamples = new List<Sample>();
OpenSamples = new List<Sample>();
string[] stringSeparators = new string[] { "<br/>" };
string[] descrSplit;
var list = xml.GetElementsByTagName("Placemark");
for (var i = 0; i < list.Count; i++)
{
var tempSample = new Sample();
var descr = xml.GetElementsByTagName("description")[i].InnerText;
descrSplit = descr.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
tempSample.ssid = Regex.Replace(descrSplit[0], @"<[^>]+>| ", "").Trim();
tempSample.ssid = tempSample.ssid.Replace("SSID: ", "");
tempSample.bssid = Regex.Replace(descrSplit[1], @"<[^>]+>| ", "").Trim();
tempSample.bssid = tempSample.bssid.Replace("BSSID: ", "");
tempSample.crypt = Regex.Replace(descrSplit[2], @"<[^>]+>| ", "").Trim();
tempSample.crypt = tempSample.crypt.Replace("Crypt: ", "");
if (tempSample.crypt == "WPA2") { WPA2Samples.Add(tempSample); }
else if (tempSample.crypt == "WpaPsk") { WPASamples.Add(tempSample); }
else if (tempSample.crypt == "Wep") { WEPSamples.Add(tempSample); }
else if (tempSample.crypt == "Open") { OpenSamples.Add(tempSample); }
tempSample.channel = Regex.Replace(descrSplit[3], @"<[^>]+>| ", "").Trim();
tempSample.channel = tempSample.channel.Replace("Channel: ", "");
tempSample.level = Regex.Replace(descrSplit[4], @"<[^>]+>| ", "").Trim();
tempSample.level = tempSample.level.Replace("Level: ", "");
tempSample.lastupdate = Regex.Replace(descrSplit[5], @"<[^>]+>| ", "").Trim();
tempSample.lastupdate = tempSample.lastupdate.Replace("Last Update: ", "");
tempSample.style = xml.GetElementsByTagName("styleUrl")[i].InnerText;
tempSample.coord = xml.GetElementsByTagName("coordinates")[i].InnerText;
allSamples.Add(tempSample);
}
textBlock1.Text = ""+list.Count+" samples";
textBlock1.Text += "\nWPA2: " + WPA2Samples.Count + " samples ("+WPA2Samples.Count/(list.Count/100)+"%)";
textBlock1.Text += "\nWPA: " + WPASamples.Count + " samples (" + WPASamples.Count / (list.Count / 100) + "%)";
textBlock1.Text += "\nWEP: " + WEPSamples.Count + " samples (" + WEPSamples.Count / (list.Count / 100) + "%)";
textBlock1.Text += "\nOpen: " + OpenSamples.Count + " samples (" + OpenSamples.Count / (list.Count / 100) + "%)";
fs.Close();
}
示例6: GetVideoMedatada
public StreamInfo GetVideoMedatada()
{
StreamInfo sinfo = new StreamInfo();
sinfo.Author = GetCanonicalUrl();
sinfo.Title = GetCanonicalUrl();
if (localInitData.Config.GetBoolean(ConfigurationConstants.ApiInternetAccess,
true, false))
{
try
{
// pobieramy informacje o video
string yt_url = GetCanonicalUrl();
string oembed = "http://www.youtube.com/oembed";
{
var qstr = HttpUtility.ParseQueryString(string.Empty);
qstr["url"] = yt_url;
qstr["format"] = "xml";
oembed += "?" + qstr.ToString();
}
WebRequest wr = WebRequest.Create(oembed);
WebResponse wre = wr.GetResponse();
Stream data = wre.GetResponseStream();
System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
xmldoc.Load(data);
data.Close();
sinfo.Author = xmldoc.GetElementsByTagName("author_name")[0].InnerText;
sinfo.Title = xmldoc.GetElementsByTagName("title")[0].InnerText;
sinfo.CanonicalUrl = GetCanonicalUrl();
}
catch (Exception)
{
sinfo.Author = "Unknown author";
sinfo.Title = "Unknown title";
sinfo.CanonicalUrl = GetCanonicalUrl();
}
}
return sinfo;
}
示例7: Subscribers
void Subscribers(Stats stats)
{
if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages))
throw new System.UnauthorizedAccessException();
string filename = System.IO.Path.Combine(Blog.CurrentInstance.StorageLocation, "newsletter.xml");
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(System.Web.Hosting.HostingEnvironment.MapPath(filename));
System.Xml.XmlNodeList list = doc.GetElementsByTagName("email");
stats.SubscribersCount += (list.Count).ToString();
}
示例8: ReadConfig
/// <summary>
/// 读取Config参数
/// </summary>
public static string ReadConfig(string name, string key)
{
System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.Load(HttpContext.Current.Server.MapPath(name + ".config"));
System.Xml.XmlNodeList xnl = xd.GetElementsByTagName(key);
if (xnl.Count == 0)
return "";
else
{
System.Xml.XmlNode mNode = xnl[0];
return mNode.InnerText;
}
}
示例9: GetTemplates
public IList<Template> GetTemplates()
{
IList<Template> list = new List<Template>();
Directory.GetDirectories(WebPathManager.TemplateUrl).ToList().ForEach(s =>
{
string dir = string.Format("{0}{1}\\", WebPathManager.TemplateUrl, s);
var xml = new System.Xml.XmlDocument();
xml.LoadXml(string.Format("{0}config.xml", dir));
var node = xml.GetElementsByTagName("template")[0];
list.Add(new Template { Name = node.Attributes["name"].Value, Url = dir, ContentUrl = node.Attributes["contentfolder"].Value, TempImage = this.GetTempImage(dir, s) });
});
return list;
}
示例10: UpdateConfig
/// <summary>
/// 保存Config参数
/// </summary>
public static void UpdateConfig(string name, string nKey, string nValue)
{
if (ReadConfig(name, nKey) != "")
{
System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
XmlDoc.Load(HttpContext.Current.Server.MapPath(name + ".config"));
System.Xml.XmlNodeList elemList = XmlDoc.GetElementsByTagName(nKey);
System.Xml.XmlNode mNode = elemList[0];
mNode.InnerText = nValue;
System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(new System.IO.StreamWriter(HttpContext.Current.Server.MapPath(name + ".config")));
xw.Formatting = System.Xml.Formatting.Indented;
XmlDoc.WriteTo(xw);
xw.Close();
}
}
示例11: GetSummariesFromText
public IDictionary<string, string> GetSummariesFromText(string text)
{
var xml = new System.Xml.XmlDocument();
xml.LoadXml(text);
var members = xml.GetElementsByTagName("members");
var member = members.Item(0).ChildNodes;
Dictionary<string,string> doc = new Dictionary<string, string>();
foreach (System.Xml.XmlNode m in member)
{
var attr = m.Attributes;
var name = attr.GetNamedItem("name");
var nodes = m.ChildNodes.Cast<System.Xml.XmlNode>();
var summary = nodes.FirstOrDefault(x=>x.Name.Equals("summary"));
if (null!=summary)
doc.Add(name.InnerText,summary.InnerText.Trim());
}
return doc;
}
示例12: Main
static void Main(string[] args)
{
WeatherService.GlobalWeather obj = new WeatherService.GlobalWeather();
string city = "Chattanooga";
string country = "United States";
System.Xml.XmlDocument xdox = new System.Xml.XmlDocument();
xdox.LoadXml(obj.GetWeather(city, country));
System.Xml.XmlNodeList nodeList = xdox.GetElementsByTagName("CurrentWeather");
foreach (System.Xml.XmlNode node in nodeList)
{
foreach (System.Xml.XmlNode childNode in node)
{
Console.WriteLine(childNode.ChildNodes.Item(0).InnerText.Trim());
}
}
}
示例13: LoadFolders
private void LoadFolders()
{
// Clear items first
lvPublishedFolders.Items.Clear();
System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
// Load XML
objXmlDocument.Load(@".\Data\PublishedFolders.xml");
// Get all Folders Tag
System.Xml.XmlNodeList objXmlNodeList = objXmlDocument.GetElementsByTagName("Folder");
// Iterate
foreach (System.Xml.XmlNode item in objXmlNodeList)
{
string Name = item.Attributes["Name"].Value;
string Status = item.Attributes["Status"].Value;
string Path = item.Attributes["Path"].Value;
// Create a Item for ListItem
ListViewItem objListViewItem = new ListViewItem(new string[] {Name,Status,Path});
objListViewItem.Selected = true;
lvPublishedFolders.Items.Add(objListViewItem);
}
}
示例14: checkForUpdate
private void checkForUpdate()
{
//check for newer version
System.Diagnostics.FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
double currentVersion = Convert.ToDouble(fv.FileVersion.Replace(".", String.Empty));
try
{
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadFile("http://www.icechat.net/update.xml", currentFolder + System.IO.Path.DirectorySeparatorChar + "update.xml");
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(currentFolder + System.IO.Path.DirectorySeparatorChar + "update.xml");
System.Xml.XmlNodeList version = xmlDoc.GetElementsByTagName("version");
System.Xml.XmlNodeList versiontext = xmlDoc.GetElementsByTagName("versiontext");
if (Convert.ToDouble(version[0].InnerText) > currentVersion)
{
this.toolStripUpdate.Visible = true;
}
else
{
this.toolStripUpdate.Visible = false;
CurrentWindowMessage(inputPanel.CurrentConnection, "You are running the latest version of IceChat (" + fv.FileVersion + ") -- Version Online = " + versiontext[0].InnerText, 4, true);
}
}
catch (Exception ex)
{
CurrentWindowMessage(inputPanel.CurrentConnection, "Error checking for update:" + ex.Message, 4, true);
}
}
示例15: GetBounceStatus
/// <summary>
/// Detects if a message is a delivery failure notification.
/// This method uses the default signatures containing in an internal ressource file.
/// </summary>
/// <remarks>
/// Signature files are XML files formatted as follows :
///
/// <?xml version='1.0'?>
/// <signatures>
/// <signature from="postmaster" subject="Undeliverable Mail" body="Unknown user" search="" />
/// ...
/// </signatures>
/// </remarks>
/// <returns>A BounceStatus object containing the level of revelance and if 100% identified, the erroneous email address.</returns>
public BounceResult GetBounceStatus(string signaturesFilePath)
{
string ressource = string.Empty;
if (signaturesFilePath == null || signaturesFilePath == string.Empty)
{
ressource = Header.GetResource("ActiveUp.Net.Mail.bouncedSignatures.xml");
}
else
ressource = System.IO.File.OpenText(signaturesFilePath).ReadToEnd();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(ressource);
BounceResult result = new BounceResult();
foreach (System.Xml.XmlElement el in doc.GetElementsByTagName("signature"))
{
if (this.From.Merged.IndexOf(el.GetElementsByTagName("from")[0].InnerText) != -1)
result.Level++;
if (this.Subject != null && this.Subject.IndexOf(el.GetElementsByTagName("subject")[0].InnerText) != -1)
result.Level++;
}
return result;
}