當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlDocument.NodeGet方法代碼示例

本文整理匯總了C#中System.Xml.XmlDocument.NodeGet方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDocument.NodeGet方法的具體用法?C# XmlDocument.NodeGet怎麽用?C# XmlDocument.NodeGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlDocument的用法示例。


在下文中一共展示了XmlDocument.NodeGet方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Yandex

 private XmlNode Yandex()
 {
     if (DateTime.Now >= _cTemplate.dtNext)
     {
         int nBuild;
         XmlNode cResult;
         XmlNode[] aItems;
         XmlDocument cXmlDocument = new XmlDocument();
         cXmlDocument.LoadXml((new System.Net.WebClient() { Encoding = Encoding.UTF8 }).DownloadString("http://news.yandex.ru/index.rss"));
         nBuild = cXmlDocument.NodeGet("rss/channel/lastBuildDate").InnerText.GetHashCode();
         if (_cTemplate.nBuild != nBuild)
         {
             aItems = cXmlDocument.NodesGet("rss/channel/item", false);
             if (null != aItems)
             {
                 _cTemplate.nBuild = nBuild;
                 cXmlDocument = new XmlDocument();
                 cResult = cXmlDocument.CreateNode(XmlNodeType.Element, "result", null);
                 XmlNode cXNItem;
                 foreach (string sItem in aItems.Select(o => o.NodeGet("title").InnerText).ToArray())
                 {
                     cXNItem = cXmlDocument.CreateNode(XmlNodeType.Element, "item", null);
                     cXNItem.InnerText = sItem.StripTags() + ".    ";
                     cResult.AppendChild(cXNItem);
                 }
                 _cTemplate.cValue = cResult;
                 _cTemplate.dt = DateTime.Now;
             }
             else
                 (new Logger()).WriteWarning("can't get any news from rss");
         }
     }
     return _cTemplate.cValue;
 }
開發者ID:ratsil,項目名稱:bethe.ingenie,代碼行數:34,代碼來源:Data.cs

示例2: Preferences

        public Preferences(string sData)
        {
            XmlDocument cXmlDocument = new XmlDocument();
            cXmlDocument.LoadXml(sData);
            XmlNode cXmlNode = cXmlDocument.NodeGet("data");

            XmlNode cNodeChild = cXmlNode.NodeGet("playlist");
            _bCuda = cNodeChild.AttributeGet<bool>("cuda");
            _nLayer = cNodeChild.AttributeGet<ushort>("layer");
            cNodeChild = cNodeChild.NodeGet("area");
            _stArea = new Area(
                    cNodeChild.AttributeGet<short>("left"),
                    cNodeChild.AttributeGet<short>("top"),
                    cNodeChild.AttributeGet<ushort>("width"),
                    cNodeChild.AttributeGet<ushort>("height")
                );
        }
開發者ID:ratsil,項目名稱:bethe.ingenie,代碼行數:17,代碼來源:Preferences.cs

示例3: Zed

				private XmlNode Zed(string sName)
				{
					if (DateTime.Now >= _cTemplate.dtNext)
					{
						int nBuild;
						XmlNode cResult, cXN, cXNChild;
						XmlAttribute cXA;
						XmlNode cXNPoll;
						XmlDocument cXmlDocument = new XmlDocument();
						cXmlDocument.LoadXml((new System.Net.WebClient() { Encoding = Encoding.UTF8 }).DownloadString("http://tvscope2014.agregator.ru/out/out_votings_one_results.phtml?dtStart=01.04.2015&dtEnd=01.04.2016"));
						nBuild = cXmlDocument.InnerXml.GetHashCode();
						if (_cTemplate.nBuild != nBuild)
						{
							string sValue;
							if (null != (cXNPoll = cXmlDocument.NodeGet("votings/voting", false)))
							{
								_cTemplate.nBuild = nBuild;
								cXmlDocument = new XmlDocument();
								cResult = cXmlDocument.CreateNode(XmlNodeType.Element, "result", null);

								if (sName.ToLower() != cXNPoll.AttributeValueGet("name").ToLower())
									throw new Exception("specified poll does not exist");
								foreach (XmlNode cXNVariant in cXNPoll.NodesGet("variant", false))
								{
									cXN = cXmlDocument.CreateNode(XmlNodeType.Element, "item", null);

									cXA = cXmlDocument.CreateAttribute("name");
									cXA.Value = cXNVariant.AttributeValueGet("name");
									cXN.Attributes.Append(cXA);
									cXA = cXmlDocument.CreateAttribute("votes");
									cXA.Value = cXNVariant.AttributeValueGet("votes");
									cXN.Attributes.Append(cXA);

									cResult.AppendChild(cXN);
								}

								_cTemplate.cValue = cResult;
								_cTemplate.dt = DateTime.Now;
							}
							else
								(new Logger()).WriteWarning("can't get any poll");
						}
					}
					return _cTemplate.cValue;
				}
開發者ID:ratsil,項目名稱:bethe.ingenie,代碼行數:45,代碼來源:Data.cs


注:本文中的System.Xml.XmlDocument.NodeGet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。