XmlSchemaCollection.Contains Method (String)


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

Namespace:   System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)

public bool Contains(
	string ns


Type: System.String

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

Return Value

Type: System.Boolean

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


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

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 = new StringWriter();
  XmlTextWriter xmlWriter = new XmlTextWriter(sw);
  xmlWriter.Formatting = Formatting.Indented;
  xmlWriter.Indentation = 2;

.NET Framework
Available since 1.1
Return to top