XmlSchemaCollection::Item Property (String^)

 

Gets the XmlSchema associated with the given namespace URI.

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

public:
property XmlSchema^ default[
	String^ ns
] {
	XmlSchema^ get(String^ ns);
}

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 = gcnew StringWriter;
   XmlTextWriter^ xmlWriter = gcnew XmlTextWriter( sw );
   xmlWriter->Formatting = Formatting::Indented;
   xmlWriter->Indentation = 2;
   schema->Write( xmlWriter );
   Console::WriteLine( sw );
}

.NET Framework
Available since 1.1
Return to top
Show: