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。