Share via


XmlSchemaCollection.Contains 方法

定義

取得值,表示具有指定命名空間的結構描述是否在集合中。

多載

Contains(String)

取得值,表示具有指定命名空間的結構描述是否在集合中。

Contains(XmlSchema)

取得值,表示指定的 XmlSchematargetNamespace 是否在集合中。

備註

重要

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

Contains(String)

Source:
XmlSchemaCollection.cs
Source:
XmlSchemaCollection.cs
Source:
XmlSchemaCollection.cs

取得值,表示具有指定命名空間的結構描述是否在集合中。

public:
 bool Contains(System::String ^ ns);
public bool Contains (string? ns);
public bool Contains (string ns);
member this.Contains : string -> bool
Public Function Contains (ns As String) As Boolean

參數

ns
String

與結構描述關聯的命名空間 URI。 對於 XML 結構描述而言,這通常會是目標命名空間。

傳回

如果具有指定命名空間的結構描述是在集合中,則為 true,否則為 false

範例

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

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 類別取代。

適用於

Contains(XmlSchema)

Source:
XmlSchemaCollection.cs
Source:
XmlSchemaCollection.cs
Source:
XmlSchemaCollection.cs

取得值,表示指定的 XmlSchematargetNamespace 是否在集合中。

public:
 bool Contains(System::Xml::Schema::XmlSchema ^ schema);
public bool Contains (System.Xml.Schema.XmlSchema schema);
member this.Contains : System.Xml.Schema.XmlSchema -> bool
Public Function Contains (schema As XmlSchema) As Boolean

參數

schema
XmlSchema

XmlSchema 物件。

傳回

如果集合中有具有相同 true 的結構描述,則為 targetNamespace,否則為 false

備註

重要

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

適用於