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.

C#
public bool Contains(string? ns);
C#
public bool Contains(string ns);

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.

C#
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());
}

Remarks

Important

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

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.

C#
public bool Contains(System.Xml.Schema.XmlSchema schema);

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

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1