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


C# XmlAttributeCollection.GetNamedItem方法代码示例

本文整理汇总了C#中System.Xml.XmlAttributeCollection.GetNamedItem方法的典型用法代码示例。如果您正苦于以下问题:C# XmlAttributeCollection.GetNamedItem方法的具体用法?C# XmlAttributeCollection.GetNamedItem怎么用?C# XmlAttributeCollection.GetNamedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlAttributeCollection的用法示例。


在下文中一共展示了XmlAttributeCollection.GetNamedItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsEqual

        private static bool IsEqual(XmlAttributeCollection left, XmlAttributeCollection right)
        {
            if (left == null)
            {
                return right == null;
            }

            if (right == null)
            {
                return false;
            }

            if (left.Count != right.Count)
            {
                return false;
            }

            foreach (XmlAttribute attr in left)
            {
                var rightAttrNode = right.GetNamedItem(attr.Name);

                if (rightAttrNode == null)
                {
                    return false;
                }

                if ((rightAttrNode as XmlAttribute).Value != attr.Value)
                {
                    return false;
                }
            }

            return true;
        }
开发者ID:Art1stical,项目名称:AHRUnrealEngine,代码行数:34,代码来源:XHTMLComparator.cs

示例2: GetAttribute

		public static string GetAttribute(XmlAttributeCollection attributes, string name)
		{
			XmlNode attr = attributes.GetNamedItem(name);
			if (attr == null)
				return "";

			return attr.Value;
		}
开发者ID:killbug2004,项目名称:WSProf,代码行数:8,代码来源:SPItemBase.cs

示例3: GetFloatAttributeValue

		/// <summary>
		/// Gets float value from XML attribute
		/// </summary>
		/// <param name="name"></param>
		/// <param name="attrs"></param>
		/// <param name="value_default"></param>
		/// <returns></returns>
		public static float GetFloatAttributeValue(string name, XmlAttributeCollection attrs, float value_default)
		{
			float r = value_default;
			try{
				XmlNode attr = attrs.GetNamedItem(name);
				if (attr != null)
				{
					r = (float)Convert.ToDouble(attr.Value);
				}
			}catch(Exception ex){
				Console.WriteLine("Error 'GetFloatAttributeValue' ["+name+"]-> "+ex.Message );
			}
			return r;
		}
开发者ID:cedricmartel,项目名称:PdfTemplate,代码行数:21,代码来源:Helper.cs

示例4: GetIntAttributeValue

		/// <summary>
		/// Gets int value from XML attribute
		/// </summary>
		/// <param name="name"></param>
		/// <param name="attrs"></param>
		/// <param name="value_default"></param>
		/// <returns></returns>
		public static int GetIntAttributeValue(string name, XmlAttributeCollection attrs, int value_default)
		{
			int r = value_default;
			try{
				XmlNode attr = attrs.GetNamedItem(name);
				if (attr != null)
				{
					r = Convert.ToInt32(attr.Value);
				}
			}catch(Exception ex){
				Console.WriteLine("Error 'GetIntAttributeValue' ->  ["+name+"]"+ex.Message );
			}
			return r;
		}
开发者ID:cedricmartel,项目名称:PdfTemplate,代码行数:21,代码来源:Helper.cs

示例5: GetAttributeValue

		/// <summary>
		/// Gets string value from XML attribute
		/// </summary>
		/// <param name="name"></param>
		/// <param name="attrs"></param>
		/// <param name="value_default"></param>
		/// <returns></returns>
		public static string GetAttributeValue(string name, XmlAttributeCollection attrs, string value_default)
		{
			string r = value_default;
			try{
				XmlNode attr = attrs.GetNamedItem(name);
				if (attr != null)
				{
					r = attr.Value;
					//Console.WriteLine(name + ": " + r);
				}
			}catch(Exception ex){
				Console.WriteLine("Error 'GetAttributeValue'  ["+name+"]-> "+ex.Message );
			}
			return r;
		}
开发者ID:cedricmartel,项目名称:PdfTemplate,代码行数:22,代码来源:Helper.cs

示例6: MyCreateEntity

        /// <summary>
        /// This function gets called by the ogmo level loader
        /// </summary>
        public static void MyCreateEntity(Scene scene, XmlAttributeCollection ogmoParameters)
        {
            //ok ogmo gives us the position in x and y, and the list of decorators in DecoratorList
            int x = ogmoParameters.Int("x", -1);
            int y = ogmoParameters.Int("y", -1);

            //this is how you read a string from ogmo
            string decoList = ogmoParameters.GetNamedItem("DecoratorList").Value;

            //create an instance
            Tank t = new Tank(x, y);

            //try and load an id; if there is none, the id will be -1
            t.NetworkId = ogmoParameters.Int("NetworkId", -1);

            //add to the scene because the decorators need that
            scene.Add(t);

            //split the decorators; they are seperated by a ":" in the DecoratorList string
            string[] decoArray = decoList.Split(':');

            //add each decorator
            foreach (string decoratorName in decoArray)
            {
                //parse the name of the decorator to the decorator-enum, and then add to the tank
                t.AddDecorator((Decorators) Enum.Parse(typeof(Decorators), decoratorName));
            }
        }
开发者ID:JOCP9733,项目名称:tank,代码行数:31,代码来源:Tank.cs

示例7: GetWs

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Get the ws value (hvo) from the wsId contained in the given attributes
		/// </summary>
		/// <param name="attribs">Collection of attributes that better have an "wsId"
		/// attribute</param>
		/// <returns></returns>
		/// -------------------------------------------------------------------------------------
		private int GetWs(XmlAttributeCollection attribs)
		{
			string wsId = attribs.GetNamedItem("wsId").Value;
			if (string.IsNullOrEmpty(wsId))
				return 0;
			return Cache.ServiceLocator.WritingSystemManager.GetWsFromStr(wsId);
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:15,代码来源:StylesXmlAccessor.cs

示例8: GetFunction

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Interpret the use attribute as a FunctionValues value
		/// </summary>
		/// <param name="attributes">Collection of attributes that better have a "use"
		/// attribute</param>
		/// <param name="styleName">Stylename being processed (for error reporting purposes)
		/// </param>
		/// <returns>The function of the style</returns>
		/// -------------------------------------------------------------------------------------
		private FunctionValues GetFunction(XmlAttributeCollection attributes,
			string styleName)
		{
			if (m_htReservedStyles.ContainsKey(styleName))
			{
				return m_htReservedStyles[styleName].function;
			}

			XmlNode node = attributes.GetNamedItem("use");
			string sFunction = (node != null) ? node.Value : null;
			if (sFunction == null)
				return FunctionValues.Prose;

			switch (sFunction)
			{
				case "prose":
				case "proseSentenceInitial":
				case "title":
				case "properNoun":
				case "special":
					return FunctionValues.Prose;
				case "line":
				case "lineSentenceInitial":
					return FunctionValues.Line;
				case "list":
					return FunctionValues.List;
				case "table":
					return FunctionValues.Table;
				case "chapter":
					return FunctionValues.Chapter;
				case "verse":
					return FunctionValues.Verse;
				case "footnote":
					return FunctionValues.Footnote;
				case "stanzabreak":
					return FunctionValues.StanzaBreak;
				default:
					Debug.Assert(false, "Unrecognized use attribute for style " + styleName +
						" in " + ResourceFileName + ": " + sFunction);
					throw new Exception(ResourceHelper.GetResourceString("kstidInvalidInstallation"));
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:52,代码来源:StylesXmlAccessor.cs

示例9: GetType

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Interpret the type attribute as a StyleType value
		/// </summary>
		/// <param name="attributes">Collection of attributes that better have a "type"
		/// attribute</param>
		/// <param name="styleName">Stylename being processed (for error reporting purposes)
		/// </param>
		/// <param name="context"></param>
		/// <returns>The type of the style</returns>
		/// -------------------------------------------------------------------------------------
		public StyleType GetType(XmlAttributeCollection attributes, string styleName,
			ContextValues context)
		{
			if (m_htReservedStyles.ContainsKey(styleName))
				return m_htReservedStyles[styleName].styleType;
			string sType = attributes.GetNamedItem("type").Value;
			ValidateContext(context, styleName);
			switch(sType)
			{
				case "paragraph":
					ValidateParagraphContext(context, styleName);
					return StyleType.kstParagraph;
				case "character":
					return StyleType.kstCharacter;
				default:
					Debug.Assert(false, "Unrecognized type attribute for style " + styleName +
						" in " + ResourceFileName + ": " + sType);
					throw new Exception(ResourceHelper.GetResourceString("kstidInvalidInstallation"));
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:31,代码来源:StylesXmlAccessor.cs

示例10: GetUnitConversion

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Retrieves the measurement units for publications and returns a multiplier for
		/// converting into millipoints.
		/// </summary>
		/// <param name="attributes">collection of XML attributes for current tag</param>
		/// <param name="attrName">name of the attribute</param>
		/// <param name="defaultVal">a default conversion factor, to be used if the specified
		/// attribute is not present in the XML</param>
		/// <returns>the multiplier for converting into millipoints</returns>
		/// -------------------------------------------------------------------------------------
		protected double GetUnitConversion(XmlAttributeCollection attributes, string attrName,
			double defaultVal)
		{
			XmlNode measUnitsNode = attributes.GetNamedItem(attrName);

			if (measUnitsNode != null)
			{
				string sMeasUnits = measUnitsNode.Value;
				switch (sMeasUnits.ToLowerInvariant())
				{
					case "inch":
						return kMpPerInch;

					case "cm":
						return kMpPerCm;

					default:
						{
							string message;
#if DEBUG
							message = "Error reading TePublications.xml: Unrecognized units for "
								+ attrName + "=\"" + measUnitsNode.Value + "\"";
#else
					message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
#endif
							throw new Exception(message);
						}
				}
			}
			else
				return defaultVal;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:43,代码来源:TePublicationsInit.cs

示例11: GetWritingSystem

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Returns a writing system ID from the named attribute
		/// </summary>
		/// <param name="attributes">collection of XML attributes for current tag</param>
		/// <param name="attrName">name of the attribute</param>
		/// <param name="defaultVal">a default to be used if no value present in the XML</param>
		/// <returns>the writing system ID integer</returns>
		/// -------------------------------------------------------------------------------------
		protected int GetWritingSystem(XmlAttributeCollection attributes,
			string attrName, int defaultVal)
		{
			XmlNode WsAttrib = attributes.GetNamedItem(attrName);
			int wsResult;

			if (WsAttrib != null && WsAttrib.Value != string.Empty)
			{
				ILgWritingSystemFactory wsf = m_scr.Cache.LanguageWritingSystemFactoryAccessor;
				wsResult = wsf.GetWsFromStr(WsAttrib.Value);

				if (wsResult != 0)
					return wsResult;
				else
				{
					// Unlike other "getAttribute" methods, this one may encounter a WS
					// that is not installed yet.
					//REVIEW: For now we will not throw an exception,
					// but try to give a meaningful message and return the default.
					string message;
					//#if DEBUG
					message = "Error reading TePublications.xml: Unrecognized writing system attribute: "
						+ attrName + "=\"" + WsAttrib.Value + "\"" + "\n Default writing system will be used.";
					//#else
					//					message = TeResourceHelper.GetResourceString("kstidInvalidInstallation");
					//#endif
					if (m_fUnderTest)
					{
						//throw new Exception(message);
						Debug.WriteLine(message);
					}
					else
					{
						MessageBox.Show(message,
							"FieldWorks", // better caption?
							MessageBoxButtons.OK, MessageBoxIcon.Warning);
					}
					return defaultVal;
				}
			}
			else
				return defaultVal;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:52,代码来源:TePublicationsInit.cs

示例12: CompareAttributes

 private static void CompareAttributes(XmlAttributeCollection attribs1, XmlAttributeCollection attribs2,
     string attribute)
 {
     var attr1 = attribs1.GetNamedItem(attribute);
     var attr2 = attribs2.GetNamedItem(attribute);
     Assert.IsFalse(attr1 == null && attr2 != null);
     Assert.IsFalse(attr1 != null && attr2 == null);
     if (attr1 != null)
         Assert.AreEqual(attr1.Value, attr2.Value);
 }
开发者ID:lgatto,项目名称:proteowizard,代码行数:10,代码来源:XmlValidationTest.cs

示例13: getValueAtributo

        private string getValueAtributo(XmlAttributeCollection coleccion, string valor)
        {
            XmlNode atributoDecisor = coleccion.GetNamedItem(_prefijo + ":" + valor);

            if (atributoDecisor != null)
            {
                return atributoDecisor.Value;
            }
            else
                return "";
        }
开发者ID:mondedos,项目名称:dotxbrl,代码行数:11,代码来源:XLinkProcesor.cs

示例14: GetPageHeightAndWidth

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the height and width of the page.
		/// </summary>
		/// <param name="attributes">collection of XML attributes for current tag</param>
		/// <param name="pub">The publication object in which the height and width are to be
		/// stored.</param>
		/// <param name="supportedPubPageSizes">The supported publication page sizes.</param>
		/// ------------------------------------------------------------------------------------
		private void GetPageHeightAndWidth(XmlAttributeCollection attributes, IPublication pub,
			XmlNode supportedPubPageSizes)
		{
			XmlNode pageSize = attributes.GetNamedItem("PageSize");

			if (pageSize != null)
			{
				string sPageSize = pageSize.Value;

				try
				{
					XmlNode pubPageSize =
						supportedPubPageSizes.SelectSingleNode("PublicationPageSize[@id='" + sPageSize + "']");
					pub.PageHeight = GetMeasurement(pubPageSize.Attributes, "Height", 0, m_conversion);
					pub.PageWidth = GetMeasurement(pubPageSize.Attributes, "Width", 0, m_conversion);
				}
				catch
				{
#if DEBUG
					throw new Exception("Error reading TePublications.xml: Problem reading PageSize. value was \"" +
						sPageSize + "\"");
#else
					pub.PageHeight = 0;
					pub.PageWidth = 0;
#endif
				}
			}
			else
			{
				pub.PageHeight = 0;
				pub.PageWidth = 0;
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:TePublicationsInit.cs

示例15: GetWs

		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Get the ws value (hvo) from the iculocale contained in the given attributes
		/// </summary>
		/// <param name="attribs">Collection of attributes that better have an "iculocale"
		/// attribute</param>
		/// <returns></returns>
		/// -------------------------------------------------------------------------------------
		private int GetWs(XmlAttributeCollection attribs)
		{
			string iculocale = attribs.GetNamedItem("iculocale").Value;
			if (iculocale == null || iculocale == string.Empty)
				return 0;

			int ws = 0;
			if (!m_htIcuToWs.TryGetValue(iculocale, out ws))
			{
				ws = m_scr.Cache.LanguageEncodings.GetWsFromIcuLocale(iculocale);
				m_htIcuToWs[iculocale] = ws;
			}
			return ws;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:22,代码来源:TeScrNoteCategoriesInit.cs


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