XmlSchemaCollection.GetEnumerator 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供以「各自獨立」方式逐一查看結構描述集合的支援。
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
傳回
列舉程式,用來逐一查看目前集合中的所有結構描述。
範例
下列範例會顯示架構集合中的每個 XML 架構。
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
備註
重要
類別 XmlSchemaCollection 已在 .NET Framework 2.0 版中過時,且已由 XmlSchemaSet 類別取代。