XmlSchemaCollection.GetEnumerator Method ()

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Provides support for the "for each" style iteration over the collection of schemas.

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

public XmlSchemaCollectionEnumerator GetEnumerator()

Return Value

Type: System.Xml.Schema.XmlSchemaCollectionEnumerator

An enumerator for iterating over all schemas in the current collection.

System_CAPS_importantImportant

The XmlSchemaCollection class is obsolete in the .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.

The following example displays each of the XML Schemas in the schema collection.

public void DisplaySchemas(XmlSchemaCollection xsc)
{
  XmlSchemaCollectionEnumerator ienum = xsc.GetEnumerator();
  while (ienum.MoveNext())
  {
    XmlSchema schema = ienum.Current;
    StringWriter sw = new StringWriter();
    XmlTextWriter writer = new XmlTextWriter(sw);
    writer.Formatting = Formatting.Indented;
    writer.Indentation = 2;
    schema.Write(writer);
    Console.WriteLine(sw.ToString());  

  }
}

.NET Framework
Available since 1.1
Return to top
Show: