This documentation is archived and is not being maintained.

XmlSchemaCollection.Item Property

Gets the XmlSchema associated with the given namespace URI.

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

public XmlSchema this [
	string ns
] { get; }
/** @property */
public XmlSchema get_Item (String ns)

JScript supports the use of indexed properties, but not the declaration of new ones.



The namespace URI associated with the schema you want to return. This will typically be the targetNamespace of the schema.

Property Value

The XmlSchema associated with the namespace URI; a null reference (Nothing in Visual Basic) if there is no loaded schema associated with the given namespace or if the namespace is associated with an XDR schema.


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;

if (xSC.Contains("urn:bookstore-schema")) {
    XmlSchema schema = xSC.get_Item("urn:bookstore-schema");
    StringWriter sW = new StringWriter();
    XmlTextWriter xmlWriter = new XmlTextWriter(sW);

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0