XmlSchemaCollection.GetEnumerator Method

Definition

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

public:
 System::Xml::Schema::XmlSchemaCollectionEnumerator ^ GetEnumerator();
public System.Xml.Schema.XmlSchemaCollectionEnumerator GetEnumerator ();
member this.GetEnumerator : unit -> System.Xml.Schema.XmlSchemaCollectionEnumerator
Public Function GetEnumerator () As XmlSchemaCollectionEnumerator

Returns

XmlSchemaCollectionEnumerator

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

Examples

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 = gcnew StringWriter;
         XmlTextWriter^ writer = gcnew XmlTextWriter( sw );
         writer->Formatting = Formatting::Indented;
         writer->Indentation = 2;
         schema->Write( writer );
         Console::WriteLine( sw );
      }
   }
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());
  }
}
Public Shared Sub Main ()
Dim xsc As XmlSchemaCollection
    Dim ienum As XmlSchemaCollectionEnumerator = xsc.GetEnumerator()
    While ienum.MoveNext()
        Dim schema As XmlSchema = ienum.Current
        Dim sw As New StringWriter()
        Dim writer As New XmlTextWriter(sw)
        writer.Formatting = Formatting.Indented
        writer.Indentation = 2
        schema.Write(writer)
        Console.WriteLine(sw.ToString())
    End While 
End Sub

Remarks

Important

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

Applies to

See also