संपादित करें

इसके माध्यम से साझा किया गया


XmlSchemaCollection.Contains Method

Definition

Gets a value indicating whether a schema with the specified namespace is in the collection.

Overloads

Contains(String)

Gets a value indicating whether a schema with the specified namespace is in the collection.

Contains(XmlSchema)

Gets a value indicating whether the targetNamespace of the specified XmlSchema is in the collection.

Remarks

Important

The XmlSchemaCollection class is obsolete in the .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.

Contains(String)

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

Gets a value indicating whether a schema with the specified namespace is in the collection.

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

Parameters

ns
String

The namespace URI associated with the schema. For XML Schemas, this will typically be the target namespace.

Returns

true if a schema with the specified namespace is in the collection; otherwise, false.

Examples

The following example checks to see if a schema is in the collection. If it is, it displays the schema.

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

Remarks

Important

The XmlSchemaCollection class is obsolete in the .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.

Applies to

Contains(XmlSchema)

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

Gets a value indicating whether the targetNamespace of the specified XmlSchema is in the collection.

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

Parameters

schema
XmlSchema

The XmlSchema object.

Returns

true if there is a schema in the collection with the same targetNamespace; otherwise, false.

Remarks

Important

The XmlSchemaCollection class is obsolete in the .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.

Applies to