XmlSchemaCollection.Item Property (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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; }

Parameters

ns
Type: System.String

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

Property Value

Type: System.Xml.Schema.XmlSchema

The XmlSchema associated with the namespace URI; null if there is no loaded schema associated with the given namespace or if the namespace is associated with an XDR schema.

System_CAPS_importantImportant

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;
  schema.Write(xmlWriter);
  Console.WriteLine(sw.ToString());
}

.NET Framework
Available since 1.1
Return to top
Show: