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


C# XmlElement.RemoveAttribute方法代码示例

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


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

示例1: RemoveXmlBase

 static void RemoveXmlBase(XmlElement element)
 {
     element.RemoveAttribute ("xml:base");
     if (!element.HasChildNodes) {
         return;
     }
     IEnumerable<XmlElement> children = element.ChildNodes.OfType<XmlElement> ();
     foreach (XmlElement child in children) {
         RemoveXmlBase (child);
     }
 }
开发者ID:Monobjc,项目名称:monobjc-tools,代码行数:11,代码来源:Program.cs

示例2: SetAttribute

        public static void SetAttribute(XmlElement Element, string Name, object Value, string DefaultValue)
        {
            if (Value == null || string.Compare(Value.ToString(), DefaultValue) == 0)
            {
                Element.RemoveAttribute(Name);
            }

            else
            {
                Element.SetAttribute(Name, Value.ToString());
            }
        }
开发者ID:rahilkidwai,项目名称:Net.Utility,代码行数:12,代码来源:XmlDocumentHelper.cs

示例3: PostProcessElement

            internal void PostProcessElement(ITemplateParsingState templateParsingState, IDictionary<string, object> getParameters, XmlElement element)
            {
                if (templateParsingState.TemplateHandlerLocator.TemplatingConstants.HtmlNamespaces.Contains(element.NamespaceURI))
                    if (element.LocalName == "script")
                    {
                        // Don't allow empty <script /> tags
                        if (null == element.InnerText)
                            element.InnerText = "";

                        if (element.InnerText.Length > 0)
                            if (!templateParsingState.WebConnection.CookiesFromBrowser.ContainsKey(templateParsingState.TemplateHandlerLocator.TemplatingConstants.JavascriptDebugModeCookie))
                                try
                                {
                                    IEnumerable<XmlNode> toIterate = Enumerable<XmlNode>.FastCopy(Enumerable<XmlNode>.Cast(element.ChildNodes));

                                    // The xml contents of a script tag are minified in case xml is quoted
                                    StringBuilder scriptBuilder = new StringBuilder((element.InnerXml.Length * 5) / 4);
                                    foreach (XmlNode node in toIterate)
                                        if (node is XmlText)
                                            scriptBuilder.Append(node.InnerText);
                                        else
                                            scriptBuilder.Append(node.OuterXml);

                                    string minified = JavaScriptMinifier.Instance.Minify(scriptBuilder.ToString());

                                    foreach (XmlNode node in toIterate)
                                        element.RemoveChild(node);

                                    element.AppendChild(
                                        templateParsingState.TemplateDocument.CreateTextNode(minified));
                                }
                                catch (Exception e)
                                {
                                    log.Warn("Exception minimizing Javascript:\n" + element.InnerXml, e);
                                }
                    }
                    else if (element.LocalName == "link")
                    {
                        string typeString = element.GetAttribute("type");
                        if (typeString == "text/css" || typeString == "image/x-icon")
                            AddBrowserCache(templateParsingState, element.Attributes["href"]);
                    }
                    else if (element.LocalName == "img")
                        AddBrowserCache(templateParsingState, element.Attributes["src"]);

                    else if (element.LocalName == "embed")
                        AddBrowserCache(templateParsingState, element.Attributes["src"]);

                    else
                    {
                        string browserCacheAttributeName = element.GetAttribute(
                            "browsercacheattribute",
                            templateParsingState.TemplateHandlerLocator.TemplatingConstants.TemplateNamespace);

                        if (browserCacheAttributeName != null)
                            if (browserCacheAttributeName.Length > 0)
                            {
                                AddBrowserCache(templateParsingState, element.Attributes[browserCacheAttributeName]);
                                element.RemoveAttribute(
                                    "browsercacheattribute",
                                    templateParsingState.TemplateHandlerLocator.TemplatingConstants.TemplateNamespace);
                            }
                    }
            }
开发者ID:GWBasic,项目名称:ObjectCloud,代码行数:64,代码来源:AggressiveCachingEnabler.cs

示例4: CleanUndoData

		void CleanUndoData (XmlElement elem)
		{
			elem.RemoveAttribute ("undoId");
			foreach (XmlNode cn in elem.ChildNodes) {
				XmlElement ce = cn as XmlElement;
				if (ce != null)
					CleanUndoData (ce);
			}
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:9,代码来源:ProjectBackend.cs

示例5: RenameAttribute

 static void RenameAttribute(XmlElement elem, string oldAttrName, string newAttrName)
 {
     elem.SetAttribute(newAttrName, elem.GetAttribute(oldAttrName));
     elem.RemoveAttribute(oldAttrName);
 }
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:5,代码来源:CodeStructure.cs

示例6: UpdateElementText

		/// <summary>
		/// Updates the Text child element if it exists otherwise updates the
		/// Text attribute.
		/// </summary>
		void UpdateElementText(XmlElement controlElement, string text)
		{
			XmlElement textElement = (XmlElement)controlElement.SelectSingleNode("w:Text", namespaceManager);
			if (textElement != null) {
				textElement.InnerText = text;
			} else if (text.Length > 0) {
				// Set text if the control text is not an empty string.
				controlElement.SetAttribute("Text", text);
			} else {
				// Remove the Text attribute.
				controlElement.RemoveAttribute("Text");
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:17,代码来源:WixDialog.cs

示例7: SetMonoDevelopProjectExtension

		public void SetMonoDevelopProjectExtension (string section, XmlElement value)
		{
			AssertCanModify ();
			var elem = GetProjectExtension ("MonoDevelop");
			if (elem == null) {
				XmlDocument doc = new XmlDocument ();
				elem = doc.CreateElement (null, "MonoDevelop", MSBuildProject.Schema);
			}
			value = (XmlElement) elem.OwnerDocument.ImportNode (value, true);
			var parent = elem;
			elem = parent ["Properties", MSBuildProject.Schema];
			if (elem == null) {
				elem = parent.OwnerDocument.CreateElement (null, "Properties", MSBuildProject.Schema);
				parent.AppendChild (elem);
				XmlUtil.Indent (format, elem, true);
			}
			XmlElement sec = elem [value.LocalName];
			if (sec == null)
				elem.AppendChild (value);
			else {
				elem.InsertAfter (value, sec);
				XmlUtil.RemoveElementAndIndenting (sec);
			}
			XmlUtil.Indent (format, value, false);
			var xmlns = value.GetAttribute ("xmlns");
			if (xmlns == Schema)
				value.RemoveAttribute ("xmlns");
			SetProjectExtension (parent);
			NotifyChanged ();
		}
开发者ID:drasticactions,项目名称:monodevelop,代码行数:30,代码来源:MSBuildProject.cs

示例8: UpdateChangedAttributes

		/// <summary>
		/// Updates the attribute values for the element.
		/// </summary>
		void UpdateChangedAttributes(XmlElement changedElement)
		{
			if (changedElement != null) {
				foreach (WixXmlAttribute attribute in view.Attributes) {
					if (String.IsNullOrEmpty(attribute.Value)) {
						changedElement.RemoveAttribute(attribute.Name);
					} else {
						changedElement.SetAttribute(attribute.Name, attribute.Value);
					}
				}
			}
		}
开发者ID:hefnerliu,项目名称:SharpDevelop,代码行数:15,代码来源:WixPackageFilesEditor.cs

示例9: SetOrRemoveAttribute

 static void SetOrRemoveAttribute(XmlElement element, string name, string value){
   if (value == null || value == string.Empty){
     if (element.HasAttribute(name))
       element.RemoveAttribute(name);
   }else{
     if (element.GetAttribute(name) != value)
       element.SetAttribute(name, value);
   }
 }
开发者ID:dbremner,项目名称:specsharp,代码行数:9,代码来源:Project.cs

示例10: UpdateImgMetdataAttributesToMatchImage

        public static void UpdateImgMetdataAttributesToMatchImage(string folderPath, XmlElement imgElement, IProgress progress, Metadata metadata)
        {
            //see also PageEditingModel.UpdateMetadataAttributesOnImage(), which does the same thing but on the browser dom
            var url = HtmlDom.GetImageElementUrl(new ElementProxy(imgElement));
            var end = url.NotEncoded.IndexOf('?');
            string fileName = url.NotEncoded;
            if (end > 0)
            {
                fileName = fileName.Substring(0, end);
            }
            if (fileName.ToLowerInvariant() == "placeholder.png" || fileName.ToLowerInvariant() == "license.png")
                return;
            if (string.IsNullOrEmpty(fileName))
            {
                Logger.WriteEvent("Book.UpdateImgMetdataAttributesToMatchImage() Warning: img has no or empty src attribute");
                //Debug.Fail(" (Debug only) img has no or empty src attribute");
                return; // they have bigger problems, which aren't appropriate to deal with here.
            }

            if (metadata == null)
            {
                // The fileName might be URL encoded.  See https://silbloom.myjetbrains.com/youtrack/issue/BL-3901.
                var path = UrlPathString.GetFullyDecodedPath(folderPath, ref fileName);
                progress.WriteStatus("Reading metadata from " + fileName);
                if (!RobustFile.Exists(path)) // they have bigger problems, which aren't appropriate to deal with here.
                {
                    imgElement.RemoveAttribute("data-copyright");
                    imgElement.RemoveAttribute("data-creator");
                    imgElement.RemoveAttribute("data-license");
                    Logger.WriteEvent("Book.UpdateImgMetdataAttributesToMatchImage()  Image " + path + " is missing");
                    //Debug.Fail(" (Debug only) Image " + path + " is missing");
                    return;
                }
                metadata = RobustIO.MetadataFromFile(path);
            }

            progress.WriteStatus("Writing metadata to HTML for " + fileName);

            imgElement.SetAttribute("data-copyright",
                             String.IsNullOrEmpty(metadata.CopyrightNotice) ? "" : metadata.CopyrightNotice);
            imgElement.SetAttribute("data-creator", String.IsNullOrEmpty(metadata.Creator) ? "" : metadata.Creator);
            imgElement.SetAttribute("data-license", metadata.License == null ? "" : metadata.License.ToString());
        }
开发者ID:BloomBooks,项目名称:BloomDesktop,代码行数:43,代码来源:ImageUpdater.cs

示例11: UpdateAttribute

        /// <summary>
        /// Updates the value of the specified token on the specified XmlElement.
        /// If the value is the same, no update is made.  If the new value is null
        /// the attribute is removed.
        /// </summary>
        private void UpdateAttribute(XmlElement root, XmlToken token, string value)
        {
            string name = GetXmlName(token);

            XmlNode oldValue = root.GetAttributeNode(name, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace);
            if (oldValue == null)
            {
                if (value == null)
                    return;
                else
                    root.SetAttribute(name, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace, value);
            }
            else
            {
                if (value == null)
                    root.RemoveAttribute(name, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace);
                else if (oldValue.Value != value)
                    root.SetAttribute(name, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace, value);
            }
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:25,代码来源:StickyNoteAnnotations.cs

示例12: RemoveKeyedNameAttributes

 /// <summary>
 /// Remove keyed_name attributes to make diffing easier
 /// </summary>
 private void RemoveKeyedNameAttributes(XmlElement node)
 {
   if (node.HasAttribute("keyed_name"))
     node.RemoveAttribute("keyed_name");
   foreach (var elem in node.Elements())
     RemoveKeyedNameAttributes(elem);
 }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:10,代码来源:ExportProcessor.cs

示例13: ProcessReferenceTag

        private static void ProcessReferenceTag(XmlElement phe, string value)
        {
            Debug.Assert(phe != null);
            Debug.Assert(!string.IsNullOrEmpty(value));

            phe.RemoveAttribute(HRefAttribute);
            phe.InnerText = value;
        }
开发者ID:Sandwych,项目名称:maltreport,代码行数:8,代码来源:ExcelMLCompiler.cs

示例14: setSettingRowDefault

        public void setSettingRowDefault(ListBoxItem lbiRow, Dictionary<ListBoxItem, XmlElement> mapLbiRow, ref XmlElement xeDef)
        {
            XmlElement xe;

            if (mapLbiRow.TryGetValue(lbiRow, out xe) && xe != null)
            {
                if (xeDef != null)
                {
                    xeDef.RemoveAttribute("isDefault");
                }
                xe.SetAttribute("isDefault", "true");
                xeDef = xe;
                refreshSetting("ThemeSetting", mx_lbTheme, m_mapLbiThemeRow, new string[0], ref m_xeThemeDef);
            }
        }
开发者ID:jaffrykee,项目名称:ui,代码行数:15,代码来源:ProjectSettingWin.xaml.cs

示例15: WriteData

        protected override XmlElement WriteData(XmlElement element) {
            // This outputs little more than what's necessary to create a custom game entry
            // Once in the file, the xml wil not need to be re-generated, so it won't need to be outputted again
            // This way manual updates to the xml file won't be lost ;)

            ID.AddAttributes(element);

            if (element.HasAttribute("name"))
                element.RemoveAttribute("name");

            element.AppendChild(Locations.XML);

            foreach (FileType type in FileTypes.Values) {
                element.AppendChild(type.XML);
            }

            foreach (string con in Contributors) {
                element.AppendChild(Game.createElement("contributor", con));
            }

            if (!String.IsNullOrEmpty(Comment))
                element.AppendChild(Game.createElement("comment", Comment));
            if (!String.IsNullOrEmpty(RestoreComment))
                element.AppendChild(Game.createElement("restore_comment", RestoreComment));


            return element;
        }
开发者ID:GameSaveInfo,项目名称:Lib.CSharp,代码行数:28,代码来源:GameVersion.cs


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