Share via


XmlElement.RemoveAttributeAt(Int32) Methode

Definition

Entfernt den Attributknoten mit dem angegebenen Index aus dem Element. (Hat das entfernte Attribut einen Standardwert, wird es sofort ersetzt.)

public:
 virtual System::Xml::XmlNode ^ RemoveAttributeAt(int i);
public virtual System.Xml.XmlNode RemoveAttributeAt (int i);
public virtual System.Xml.XmlNode? RemoveAttributeAt (int i);
abstract member RemoveAttributeAt : int -> System.Xml.XmlNode
override this.RemoveAttributeAt : int -> System.Xml.XmlNode
Public Overridable Function RemoveAttributeAt (i As Integer) As XmlNode

Parameter

i
Int32

Der Index des zu entfernenden Knotens. Der erste Knoten hat den Index 0.

Gibt zurück

XmlNode

Der entfernte Attributknoten oder null, wenn für den angegebenen Index kein Knoten vorhanden ist.

Beispiele

Im folgenden Beispiel wird ein Attribut aus einem Element entfernt.

#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->RemoveAttributeAt( 0 );
   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.RemoveAttributeAt(0);

    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.RemoveAttributeAt(0)

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

  end sub
end class

Hinweise

Diese Methode ist eine Microsoft-Erweiterung für das Document-Objektmodell (DOM).

Gilt für