XmlSchemaCollection::GetEnumerator Method ()

 

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 = gcnew StringWriter;
         XmlTextWriter^ writer = gcnew XmlTextWriter( sw );
         writer->Formatting = Formatting::Indented;
         writer->Indentation = 2;
         schema->Write( writer );
         Console::WriteLine( sw );
      }
   }

.NET Framework
Available since 1.1
Return to top
Show: