XmlSchemaCollection.Item[String] Proprietà

Definizione

Ottiene l'XmlSchema associato all'URI dello spazio dei nomi dato.

public:
 property System::Xml::Schema::XmlSchema ^ default[System::String ^] { System::Xml::Schema::XmlSchema ^ get(System::String ^ ns); };
public System.Xml.Schema.XmlSchema? this[string? ns] { get; }
public System.Xml.Schema.XmlSchema this[string ns] { get; }
member this.Item(string) : System.Xml.Schema.XmlSchema
Default Public ReadOnly Property Item(ns As String) As XmlSchema

Parametri

ns
String

URI dello spazio dei nomi associato allo schema che dovrà essere restituito. Sarà generalmente il targetNamespace dello schema.

Valore della proprietà

XmlSchema associato all'URI dello spazio dei nomi. null se non è presente uno schema caricato associato allo spazio dei nomi considerato oppure se lo spazio dei nomi è associato a uno schema XDR.

Esempio

Nell'esempio seguente viene verificato se uno schema si trova nella raccolta. In caso affermativo, viene visualizzato lo 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 );
}
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("urn:bookstore-schema") Then
    Dim schema As XmlSchema = xsc("urn:bookstore-schema")
    Dim sw As New StringWriter()
    Dim xmlWriter As New XmlTextWriter(sw)
    xmlWriter.Formatting = Formatting.Indented
    xmlWriter.Indentation = 2
    schema.Write(xmlWriter)
    Console.WriteLine(sw.ToString())
End If

Commenti

Importante

La XmlSchemaCollection classe è obsoleta in .NET Framework versione 2.0 ed è stata sostituita dalla XmlSchemaSet classe .

Si applica a