This topic has not yet been rated - Rate this topic

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

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.
Important noteImportant Note:

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());
}
if (xsc->Contains(S"urn:bookstore-schema"))
{
  XmlSchema* schema = xsc->Item[S"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);
}

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

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.