XmlElement.RemoveAttributeNode 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
删除一个 XmlAttribute.
重载
| 名称 | 说明 |
|---|---|
| RemoveAttributeNode(XmlAttribute) |
删除指定的 XmlAttribute。 |
| RemoveAttributeNode(String, String) |
XmlAttribute删除本地名称和命名空间 URI 指定的值。 (如果已删除的属性具有默认值,则立即替换它)。 |
RemoveAttributeNode(XmlAttribute)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
删除指定的 XmlAttribute。
public:
virtual System::Xml::XmlAttribute ^ RemoveAttributeNode(System::Xml::XmlAttribute ^ oldAttr);
public virtual System.Xml.XmlAttribute RemoveAttributeNode(System.Xml.XmlAttribute oldAttr);
public virtual System.Xml.XmlAttribute? RemoveAttributeNode(System.Xml.XmlAttribute oldAttr);
abstract member RemoveAttributeNode : System.Xml.XmlAttribute -> System.Xml.XmlAttribute
override this.RemoveAttributeNode : System.Xml.XmlAttribute -> System.Xml.XmlAttribute
Public Overridable Function RemoveAttributeNode (oldAttr As XmlAttribute) As XmlAttribute
参数
- oldAttr
- XmlAttribute
要删除的 XmlAttribute 节点。 如果已删除的属性具有默认值,则会立即替换它。
返回
已删除XmlAttribute,或者null不是oldAttr该属性节点。XmlElement
例外
此节点是只读的。
适用于
RemoveAttributeNode(String, String)
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
- Source:
- XmlElement.cs
XmlAttribute删除本地名称和命名空间 URI 指定的值。 (如果已删除的属性具有默认值,则立即替换它)。
public:
virtual System::Xml::XmlAttribute ^ RemoveAttributeNode(System::String ^ localName, System::String ^ namespaceURI);
public virtual System.Xml.XmlAttribute RemoveAttributeNode(string localName, string namespaceURI);
public virtual System.Xml.XmlAttribute? RemoveAttributeNode(string localName, string? namespaceURI);
abstract member RemoveAttributeNode : string * string -> System.Xml.XmlAttribute
override this.RemoveAttributeNode : string * string -> System.Xml.XmlAttribute
Public Overridable Function RemoveAttributeNode (localName As String, namespaceURI As String) As XmlAttribute
参数
- localName
- String
特性的本地名称。
- namespaceURI
- String
特性的命名空间 URI。
返回
已删除XmlAttributenull或如果没有XmlElement匹配的属性节点。
例外
此节点是只读的。
示例
以下示例从元素中删除属性。
using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlDocument doc = new XmlDocument();
doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" +
"<title>Pride And Prejudice</title>" +
"</book>");
XmlElement root = doc.DocumentElement;
// Remove the ISBN attribute.
root.RemoveAttributeNode("ISBN", "urn:samples");
Console.WriteLine("Display the modified XML...");
Console.WriteLine(doc.InnerXml);
}
}
Imports System.IO
Imports System.Xml
public class Sample
public shared sub Main()
Dim doc as XmlDocument = new XmlDocument()
doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-861001-57-5'>" & _
"<title>Pride And Prejudice</title>" & _
"</book>")
Dim root as XmlElement = doc.DocumentElement
' Remove the ISBN attribute.
root.RemoveAttributeNode("ISBN", "urn:samples")
Console.WriteLine("Display the modified XML...")
Console.WriteLine(doc.InnerXml)
end sub
end class