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


C# XmlElement.GetAttributeNode方法代码示例

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


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

示例1: Load

		public override void Load (XmlElement filenode, FilePath baseDirectory)
		{
			var extAtt = filenode.GetAttributeNode ("extension");
			if (extAtt != null)
				extension = extAtt.Value ?? "";

			propertyInnerText = filenode.InnerText;
			if (propertyInnerText == null)
				throw new InvalidOperationException ("Property is missing its inner text");

			typeAtt = filenode.GetAttributeNode ("type");
			if (typeAtt == null)
				throw new InvalidOperationException ("Property is missing the type attribute");

			if (String.IsNullOrEmpty (typeAtt.Value))
				throw new InvalidOperationException ("Property's type attribute is empty");

			if (String.IsNullOrEmpty (filenode.InnerText))
				throw new InvalidOperationException ("Property is empty");
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:20,代码来源:PropertyDescriptionTemplate.cs

示例2: assert_throttle

        public static IAssertion assert_throttle(XmlElement config)
        {
            var delay = new TimeSpan();

            XmlAttribute attribute = config.GetAttributeNode("delayTimeSpan");

            if (attribute != null)
            {
                delay = TimeSpan.Parse(attribute.Value);
            }

            bool trace = false;

            attribute = config.GetAttributeNode("traceThrottledExceptions");

            if (attribute != null)
            {
                trace = bool.Parse(attribute.Value);
            }

            return new ThrottleAssertion(delay, trace);
        }
开发者ID:scottccoates,项目名称:CliqFlip,代码行数:22,代码来源:AssertionFactory.cs

示例3: LoadData

        /// <summary>
        /// Extracts the data from the DOM tree below the indicated context
        /// <see cref="XmlElement"/> and create a suitable <see crel="Release"/>
        /// structure to add to the indicated <see cref="Specification"/>.
        /// </summary>
        /// <param name="specification">The owning <see cref="Specification"/>.</param>
        /// <param name="context">The context <see cref="XmlElement"/> containing data</param>
        /// <param name="loadedSchemas">A dictionary of all ready loaded schemas.</param>
        public virtual void LoadData(Specification specification, XmlElement context,
            Dictionary<string, SchemaRelease> loadedSchemas)
        {
            XmlAttribute	id 		= context.GetAttributeNode ("id");

            SchemaRelease release = new SchemaRelease (specification,
                    GetVersion (context), GetNamespaceUri (context),
                    GetSchemaLocation (context), GetPreferredPrefix (context),
                    GetAlternatePrefix (context), GetRootElements (context));

            HandleImports (release, context, loadedSchemas);

            if (id != null) loadedSchemas.Add (id.Value, release);
        }
开发者ID:formicary,项目名称:fpml-toolkit-csharp,代码行数:22,代码来源:DefaultSchemaReleaseLoader.cs

示例4: SortAttributesAttributes

 private void SortAttributesAttributes(XmlElement el)
 {
     ArrayList al = new ArrayList();
     foreach (XmlAttribute a in el.Attributes)
         al.Add(a.Name);
     al.Sort();
     string[] names = (string[])al.ToArray(typeof(string));
     al.Clear();
     foreach (string name in names)
         al.Add(el.RemoveAttributeNode(
             el.GetAttributeNode(name)));
     foreach (XmlAttribute a in al)
         // Exclude xmlns="" here.
         if (a.Name != "xmlns")// || a.Value != String.Empty)
             el.SetAttributeNode(a);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:DataSetAssertion.cs

示例5: LoadData

        /// <summary>
        /// Extracts the data from the DOM tree below the indicated context
        /// <see cref="XmlElement"/> and create a suitable <see cref="HandCoded.Meta.Release"/>
        /// structure to add to the indicated <see cref="HandCoded.Meta.Specification"/>.
        /// </summary>
        /// <param name="specification">The owning <see cref="HandCoded.Meta.Specification"/>.</param>
        /// <param name="context">The context <see cref="XmlElement"/> containing data</param>
        /// <param name="loadedSchemas">A dictionary of all ready loaded schemas.</param>
        public override void LoadData(HandCoded.Meta.Specification specification, XmlElement context,
            Dictionary<string, HandCoded.Meta.SchemaRelease> loadedSchemas)
        {
            XmlAttribute    id 		= context.GetAttributeNode ("id");

            SchemaRelease release = new SchemaRelease (specification,
                    GetVersion (context), GetNamespaceUri (context),
                    GetSchemaLocation (context), GetPreferredPrefix (context),
                    GetAlternatePrefix (context),
                    new FpMLInstanceInitialiser (),
                    new FpMLSchemaRecogniser (), GetRootElements (context),
                    GetSchemeDefaults (context), GetSchemeCollection (context));

            HandleImports (release, context, loadedSchemas);

            if (id != null) loadedSchemas.Add (id.Value, release);
        }
开发者ID:formicary,项目名称:fpml-toolkit-csharp,代码行数:25,代码来源:FpMLSchemaReleaseLoader.cs

示例6: InspectProgressTextElement

        /// <summary>
        /// Inspects a ProgressText element.
        /// </summary>
        /// <param name="element">The ProgressText element to inspect.</param>
        private void InspectProgressTextElement(XmlElement element)
        {
            XmlAttribute template = element.GetAttributeNode("Template");

            if (null != template && String.Empty == template.Value)
            {
                this.OnError(InspectorTestType.ProgressTextTemplateEmpty, element, "The ProgressText/@Template attribute's value cannot be the empty string.");
                element.Attributes.Remove(template);
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:14,代码来源:Inspector.cs

示例7: InspectMediaElement

        /// <summary>
        /// Inspects a Media element.
        /// </summary>
        /// <param name="element">The Media element to inspect.</param>
        private void InspectMediaElement(XmlElement element)
        {
            XmlAttribute src = element.GetAttributeNode("src");

            if (null != src)
            {
                this.OnError(InspectorTestType.SrcIsDeprecated, src, "The Media/@src attribute has been deprecated.  Use the Layout attribute instead.");

                XmlAttribute layout = element.OwnerDocument.CreateAttribute("Layout");
                layout.Value = src.Value;
                element.Attributes.InsertAfter(layout, src);

                element.Attributes.Remove(src);
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:19,代码来源:Inspector.cs

示例8: InspectFileSearchElement

        /// <summary>
        /// Inspects a FileSearch element.
        /// </summary>
        /// <param name="element">The FileSearch element to inspect.</param>
        private void InspectFileSearchElement(XmlElement element)
        {
            XmlAttribute name = element.GetAttributeNode("Name");
            XmlAttribute longName = element.GetAttributeNode("LongName");

            // check for a short/long filename separator in the Name attribute
            if (null != name && 0 <= name.Value.IndexOf('|'))
            {
                if (null == longName) // long name is not present, split the Name if possible
                {
                    string[] names = name.Value.Split("|".ToCharArray());

                    // this appears to be splittable
                    if (2 == names.Length)
                    {
                        this.OnError(InspectorTestType.FileSearchNamesCombined, element, "The FileSearch/@Name attribute appears to contain both a short and long file name.  It may only contain an 8.3 file name.  Also use the LongName attribute to specify a longer name.");

                        // fix the short name
                        name.Value = names[0];

                        // insert the new LongName attribute after the previous Name attribute
                        longName = element.OwnerDocument.CreateAttribute("LongName");
                        longName.Value = names[1];
                        element.Attributes.InsertAfter(longName, name);
                    }
                }
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:32,代码来源:Inspector.cs

示例9: InspectControlElement

        /// <summary>
        /// Inspects a Control element.
        /// </summary>
        /// <param name="element">The Control element to inspect.</param>
        private void InspectControlElement(XmlElement element)
        {
            XmlAttribute checkBoxValue = element.GetAttributeNode("CheckBoxValue");

            if (null != checkBoxValue && String.Empty == checkBoxValue.Value)
            {
                this.OnError(InspectorTestType.IniFileValueEmpty, element, "The Control/@CheckBoxValue attribute's value cannot be the empty string.");
                element.Attributes.Remove(checkBoxValue);
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:14,代码来源:Inspector.cs

示例10: InspectClassElement

        /// <summary>
        /// Inspects a Class element.
        /// </summary>
        /// <param name="element">The Class element to inspect.</param>
        private void InspectClassElement(XmlElement element)
        {
            bool advertised = false;
            XmlAttribute description = element.GetAttributeNode("Description");
            XmlAttribute relativePath = element.GetAttributeNode("RelativePath");

            if (null != description && String.Empty == description.Value)
            {
                this.OnError(InspectorTestType.ClassDescriptionEmpty, element, "The Class/@Description attribute's value cannot be an empty string.");
                element.Attributes.Remove(description);
            }

            if (null != relativePath)
            {
                // check if this element or any of its parents is advertised
                for (XmlNode node = element; null != node; node = node.ParentNode)
                {
                    if (node.Attributes != null)
                    {
                        XmlNode advertise = node.Attributes.GetNamedItem("Advertise");

                        if (null != advertise && "yes" == advertise.Value)
                        {
                            advertised = true;
                        }
                    }
                }

                if (advertised) // if advertised, then RelativePath="no" is unnecessary since its the default value
                {
                    if ("no" == relativePath.Value)
                    {
                        this.OnVerbose(element, "The Class/@RelativePath attribute with value 'no' is not necessary since this element is advertised.");
                        element.Attributes.Remove(relativePath);
                    }
                }
                else // if there is no advertising, then the RelativePath attribute is not allowed
                {
                    this.OnError(InspectorTestType.ClassRelativePathMustBeAdvertised, element, "The Class/@RelativePath attribute is not supported for non-advertised Class elements.");
                    element.Attributes.Remove(relativePath);
                }
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:47,代码来源:Inspector.cs

示例11: InspectWebApplicationExtensionElement

        /// <summary>
        /// Inspects a WebApplicationExtension element.
        /// </summary>
        /// <param name="element">The WebApplicationExtension element to inspect.</param>
        private void InspectWebApplicationExtensionElement(XmlElement element)
        {
            XmlAttribute extension = element.GetAttributeNode("Extension");
            XmlAttribute id = element.GetAttributeNode("Id");

            if (null != id)
            {
                // an empty Id attribute value should be replaced with "*"
                if (String.Empty == id.Value)
                {
                    this.OnError(InspectorTestType.WebApplicationExtensionIdEmpty, element, "The WebApplicationExtension/@Id attribute's value cannot be an empty string.  Use '*' for the value instead.");
                    id.Value = "*";
                }

                // Id has been deprecated, use Extension instead
                if (null == extension)
                {
                    this.OnError(InspectorTestType.WebApplicationExtensionIdDeprecated, element, "The WebApplicationExtension/@Id attribute has been deprecated.  Use the Extension attribute instead.");
                    extension = element.OwnerDocument.CreateAttribute("Extension");
                    extension.Value = id.Value;
                    element.Attributes.InsertAfter(extension, id);
                    element.Attributes.Remove(id);
                }
            }
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:29,代码来源:Inspector.cs

示例12: ParseArgument

        private static object ParseArgument(ParameterInfo parameter, XmlElement config)
        {
            Debug.Assert(parameter != null);
            Debug.Assert(config != null);

            var name = parameter.Name;
            var type = parameter.ParameterType;
            string text;

            var attribute = config.GetAttributeNode(name);
            if (attribute != null)
            {
                text = attribute.Value;
            }
            else
            {
                var element = config[name];
                if (element == null)
                    return null;

                text = element.InnerText;
            }

            if (type == typeof(IContextExpression))
                return new WebDataBindingExpression(text);

            if (type == typeof(Type))
                return TypeResolution.GetType(text);

            if (type == typeof(bool))
            {
                text = text.Trim().ToLowerInvariant();
                return Boolean.TrueString.Equals(StringTranslation.Translate(Boolean.TrueString, text, _truths));
            }

            var converter = TypeDescriptor.GetConverter(type);
            return converter.ConvertFromInvariantString(text);
        }
开发者ID:boena,项目名称:elmah-with-custom-data,代码行数:38,代码来源:AssertionFactory.cs

示例13: MoveToAttributeFromElement

 private bool MoveToAttributeFromElement(XmlElement elem, string name, string ns)
 {
     XmlAttribute node = null;
     if (ns.Length == 0)
     {
         node = elem.GetAttributeNode(name);
     }
     else
     {
         node = elem.GetAttributeNode(name, ns);
     }
     if (node != null)
     {
         this.bOnAttrVal = false;
         this.elemNode = elem;
         this.curNode = node;
         this.attrIndex = elem.Attributes.FindNodeOffsetNS(node);
         if (this.attrIndex != -1)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:XmlNodeReaderNavigator.cs

示例14: GetAttributeFromElement

 private string GetAttributeFromElement(XmlElement elem, string name, string ns)
 {
     XmlAttribute attributeNode = elem.GetAttributeNode(name, ns);
     if (attributeNode != null)
     {
         return attributeNode.Value;
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:XmlNodeReaderNavigator.cs

示例15: PathHasDuplicateNamespace

 private bool PathHasDuplicateNamespace(XmlElement top, XmlElement bottom, string localName)
 {
     string strReservedXmlns = this.document.strReservedXmlns;
     while ((bottom != null) && (bottom != top))
     {
         if (bottom.GetAttributeNode(localName, strReservedXmlns) != null)
         {
             return true;
         }
         bottom = bottom.ParentNode as XmlElement;
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:DocumentXPathNavigator.cs


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