共用方式為


XmlSchemaCollection.Item[String] 屬性

定義

取得與指定的命名空間 URI 關聯的 XmlSchema

public:
 property System::Xml::Schema::XmlSchema ^ default[System::String ^] { System::Xml::Schema::XmlSchema ^ get(System::String ^ ns); };
public System.Xml.Schema.XmlSchema? this[string? ns] { get; }
public System.Xml.Schema.XmlSchema this[string ns] { get; }
member this.Item(string) : System.Xml.Schema.XmlSchema
Default Public ReadOnly Property Item(ns As String) As XmlSchema

參數

ns
String

與您要傳回的結構描述相關聯的命名空間 URI。 這通常是結構描述的 targetNamespace

屬性值

與命名空間 URI 相關聯的 XmlSchema,如果載入的結構描述與指定的命名空間無關聯,或者命名空間與 XDR 結構描述相關聯,則為 null

範例

下列範例會檢查架構是否在集合中。 如果是,則會顯示架構。

if ( xsc->Contains( "urn:bookstore-schema" ) )
{
   XmlSchema^ schema = xsc[ "urn:bookstore-schema" ];
   StringWriter^ sw = gcnew StringWriter;
   XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( sw );
   xmlWriter->Formatting = Formatting::Indented;
   xmlWriter->Indentation = 2;
   schema->Write( xmlWriter );
   Console::WriteLine( sw );
}
if (xsc.Contains("urn:bookstore-schema"))
{
  XmlSchema schema = xsc["urn:bookstore-schema"];
  StringWriter sw = new StringWriter();
  XmlTextWriter xmlWriter = new XmlTextWriter(sw);
  xmlWriter.Formatting = Formatting.Indented;
  xmlWriter.Indentation = 2;
  schema.Write(xmlWriter);
  Console.WriteLine(sw.ToString());
}
If xsc.Contains("urn:bookstore-schema") Then
    Dim schema As XmlSchema = xsc("urn:bookstore-schema")
    Dim sw As New StringWriter()
    Dim xmlWriter As New XmlTextWriter(sw)
    xmlWriter.Formatting = Formatting.Indented
    xmlWriter.Indentation = 2
    schema.Write(xmlWriter)
    Console.WriteLine(sw.ToString())
End If

備註

重要

類別 XmlSchemaCollection 已在 .NET Framework 2.0 版中過時,且已由 XmlSchemaSet 類別取代。

適用於