XmlElement.RemoveAttribute 메서드

정의

지정된 특성을 제거합니다. 제거한 특성에 기본값이 있는 경우 즉시 바뀝니다.

오버로드

RemoveAttribute(String)

이름을 사용하여 특성을 제거합니다.

RemoveAttribute(String, String)

지정된 로컬 이름과 네임스페이스 URI를 갖고 있는 특성을 제거합니다. 제거한 특성에 기본값이 있는 경우 즉시 바뀝니다.

RemoveAttribute(String)

이름을 사용하여 특성을 제거합니다.

public:
 virtual void RemoveAttribute(System::String ^ name);
public virtual void RemoveAttribute (string name);
abstract member RemoveAttribute : string -> unit
override this.RemoveAttribute : string -> unit
Public Overridable Sub RemoveAttribute (name As String)

매개 변수

name
String

제거할 특성의 이름입니다. 정규화된 이름입니다. 일치하는 노드의 Name 속성과 일치합니다.

예외

노드는 읽기 전용입니다.

예제

다음 예제에서는 요소에서 특성을 제거합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew XmlDocument;
   doc->LoadXml( "<book genre='novel' ISBN='1-861001-57-5'><title>Pride And Prejudice</title></book>" );
   XmlElement^ root = doc->DocumentElement;
   
   // Remove the genre attribute.
   root->RemoveAttribute( "genre" );
   Console::WriteLine( "Display the modified XML..." );
   Console::WriteLine( doc->InnerXml );
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    XmlDocument doc = new XmlDocument();
    doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
                "<title>Pride And Prejudice</title>" +
                "</book>");

    XmlElement root = doc.DocumentElement;

    // Remove the genre attribute.
    root.RemoveAttribute("genre");

    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 genre='novel' ISBN='1-861001-57-5'>" & _
                "<title>Pride And Prejudice</title>" & _
                "</book>")      

    Dim root as XmlElement = doc.DocumentElement

    ' Remove the genre attribute.
    root.RemoveAttribute("genre")

    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.InnerXml)

  end sub
end class

설명

제거된 특성에 기본값이 있는 것으로 알려진 경우 기본값 및 해당하는 경우 해당 네임스페이스 URI, 로컬 이름 및 접두사가 포함된 특성이 즉시 나타납니다.

적용 대상

RemoveAttribute(String, String)

지정된 로컬 이름과 네임스페이스 URI를 갖고 있는 특성을 제거합니다. 제거한 특성에 기본값이 있는 경우 즉시 바뀝니다.

public:
 virtual void RemoveAttribute(System::String ^ localName, System::String ^ namespaceURI);
public virtual void RemoveAttribute (string localName, string namespaceURI);
public virtual void RemoveAttribute (string localName, string? namespaceURI);
abstract member RemoveAttribute : string * string -> unit
override this.RemoveAttribute : string * string -> unit
Public Overridable Sub RemoveAttribute (localName As String, namespaceURI As String)

매개 변수

localName
String

제거할 특성의 로컬 이름입니다.

namespaceURI
String

제거할 특성의 네임스페이스 URI입니다.

예외

노드는 읽기 전용입니다.

예제

다음 예제에서는 요소에서 특성을 제거합니다.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   XmlDocument^ doc = gcnew 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->RemoveAttribute( "ISBN", "urn:samples" );
   Console::WriteLine( "Display the modified XML..." );
   Console::WriteLine( doc->InnerXml );
}
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.RemoveAttribute("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.RemoveAttribute("ISBN", "urn:samples")
    
    Console.WriteLine("Display the modified XML...")
    Console.WriteLine(doc.InnerXml)

  end sub
end class

설명

제거된 특성에 기본값이 있는 것으로 알려진 경우 기본값 및 해당하는 경우 해당 네임스페이스 URI, 로컬 이름 및 접두사가 포함된 특성이 즉시 나타납니다.

적용 대상