Freigeben über


XmlNamedNodeMap.Count-Eigenschaft

Ruft die Anzahl der Knoten in der XmlNamedNodeMap ab.

Namespace: System.Xml
Assembly: System.Xml (in system.xml.dll)

Syntax

'Declaration
Public Overridable ReadOnly Property Count As Integer
'Usage
Dim instance As XmlNamedNodeMap
Dim value As Integer

value = instance.Count
public virtual int Count { get; }
public:
virtual property int Count {
    int get ();
}
/** @property */
public int get_Count ()
public function get Count () : int

Eigenschaftenwert

Die Anzahl der Knoten.

Beispiel

Im folgenden Beispiel werden mit der XmlAttributeCollection-Klasse (die von XmlNamedNodeMap erbt) alle Attribute eines Buches angezeigt.

Imports System
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    Dim doc as XmlDocument = new XmlDocument()
    doc.LoadXml("<book genre='novel' publicationdate='1997'> " & _
                "  <title>Pride And Prejudice</title>" & _
                "</book>")
                         
    Dim attrColl as XmlAttributeCollection = doc.DocumentElement.Attributes

    Console.WriteLine("Display all the attributes for this book...")
    Dim i As Integer
    For i = 0 To attrColl.Count - 1
       Console.WriteLine("{0} = {1}", attrColl.Item(i).Name,attrColl.Item(i).Value)
    Next
    
  end sub
end class
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     XmlDocument doc = new XmlDocument();
     doc.LoadXml("<book genre='novel' publicationdate='1997'> " +
                 "  <title>Pride And Prejudice</title>" +
                 "</book>");      
 
     XmlAttributeCollection attrColl = doc.DocumentElement.Attributes;

     Console.WriteLine("Display all the attributes for this book...");
     for (int i=0; i < attrColl.Count; i++)
     {
        Console.WriteLine("{0} = {1}", attrColl.Item(i).Name, attrColl.Item(i).Value);
     }         
    
  }
}
#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' publicationdate='1997'>   <title>Pride And Prejudice</title></book>" );
   XmlAttributeCollection^ attrColl = doc->DocumentElement->Attributes;
   Console::WriteLine( "Display all the attributes for this book..." );
   for ( int i = 0; i < attrColl->Count; i++ )
   {
      Console::WriteLine( "{0} = {1}", attrColl->Item( i )->Name, attrColl->Item( i )->Value );

   }
}
import System.*;
import System.IO.*;
import System.Xml.*;

public class Sample
{
    public static void main(String[] args)
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<book genre='novel' publicationdate='1997'> "
            + "  <title>Pride And Prejudice</title>"
            + "</book>");

        XmlAttributeCollection attrColl = 
            doc.get_DocumentElement().get_Attributes();

        Console.WriteLine("Display all the attributes for this book...");
        for (int i = 0; i < attrColl.get_Count(); i++) {
            Console.WriteLine("{0} = {1}", attrColl.Item(i).get_Name(), 
                attrColl.Item(i).get_Value());
        }
    } //main 
} //Sample

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

XmlNamedNodeMap-Klasse
XmlNamedNodeMap-Member
System.Xml-Namespace