当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlDocument.GetElementsByTagName方法代码示例

本文整理汇总了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));
        }
开发者ID:XF9,项目名称:Fenrir,代码行数:65,代码来源:GameProperties.cs

示例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();
        }
开发者ID:sst330381,项目名称:pinker-stone,代码行数:48,代码来源:Program.cs

示例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();
        }
开发者ID:poxet,项目名称:Rubicon-Reverse-Proxy,代码行数:26,代码来源:RedirectRuleManager.cs

示例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();
        }
开发者ID:BrookHuang,项目名称:XYFrame,代码行数:25,代码来源:HttpModule.cs

示例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], @"<[^>]+>|&nbsp;", "").Trim();
                tempSample.ssid = tempSample.ssid.Replace("SSID: ", "");
                tempSample.bssid = Regex.Replace(descrSplit[1], @"<[^>]+>|&nbsp;", "").Trim();
                tempSample.bssid = tempSample.bssid.Replace("BSSID: ", "");
                tempSample.crypt = Regex.Replace(descrSplit[2], @"<[^>]+>|&nbsp;", "").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], @"<[^>]+>|&nbsp;", "").Trim();
                tempSample.channel = tempSample.channel.Replace("Channel: ", "");
                tempSample.level = Regex.Replace(descrSplit[4], @"<[^>]+>|&nbsp;", "").Trim();
                tempSample.level = tempSample.level.Replace("Level: ", "");
                tempSample.lastupdate = Regex.Replace(descrSplit[5], @"<[^>]+>|&nbsp;", "").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();
        }
开发者ID:JordyRits,项目名称:InformationSecurity,代码行数:47,代码来源:MainWindow.xaml.cs

示例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;
		}
开发者ID:psychob,项目名称:livestreamer-gui,代码行数:46,代码来源:YouTubeCom.cs

示例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();
        }
开发者ID:ildragocom,项目名称:BlogEngine.NET,代码行数:11,代码来源:StatsRepository.cs

示例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;
     }
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:16,代码来源:XmlCOM.cs

示例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;
        }
开发者ID:hanwest00,项目名称:MYTestWeb,代码行数:14,代码来源:PagesService.cs

示例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();
     }
 }
开发者ID:WZDotCMS,项目名称:WZDotCMS,代码行数:18,代码来源:XmlCOM.cs

示例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;
 }
开发者ID:Lundalogik,项目名称:isop,代码行数:18,代码来源:HelpXmlDocumentation.cs

示例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());
                }
            }
        }
开发者ID:tyn53,项目名称:WeatherProject,代码行数:18,代码来源:Program.cs

示例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);
            }
        }
开发者ID:BGCX262,项目名称:zynchronyze-svn-to-git,代码行数:24,代码来源:Form1.cs

示例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);
            }
        }
开发者ID:origins,项目名称:ICEChat,代码行数:30,代码来源:FormMain.cs

示例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 : 
        /// 
        /// &lt;?xml version='1.0'?&gt;
        /// &lt;signatures&gt;
        ///		&lt;signature from=&quot;postmaster&quot; subject=&quot;Undeliverable Mail&quot; body=&quot;Unknown user&quot; search=&quot;&quot; />
        ///		...
        /// &lt;/signatures&gt;
        /// </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;
        }
开发者ID:haoasqui,项目名称:MailSystem.NET,代码行数:39,代码来源:Header.cs


注:本文中的System.Xml.XmlDocument.GetElementsByTagName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。