XmlNamedNodeMap.Count Property

 

Gets the number of nodes in the XmlNamedNodeMap.

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

public virtual int Count { get; }

Property Value

Type: System.Int32

The number of nodes.

The following example uses the XmlAttributeCollection class (which inherits from XmlNamedNodeMap) to display all the attributes of a book.

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);
     }         

  }
}

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: