XmlSchemaCollection.Item[String] Propriedade

Definição

Obtém o XmlSchema associado ao URI de namespace determinado.

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

Parâmetros

ns
String

O URI do namespace associado ao esquema que você deseja retornar. Isso geralmente será o targetNamespace do esquema.

Valor da propriedade

XmlSchema

O XmlSchema URI do namespace associado; null se não houver nenhum esquema carregado associado ao namespace fornecido ou se o namespace estiver associado a um esquema XDR.

Exemplos

O exemplo a seguir verifica se um esquema está na coleção. Se for, ele exibirá o esquema.

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

Comentários

Importante

A XmlSchemaCollection classe está obsoleta no .NET Framework versão 2.0 e foi substituída pela XmlSchemaSet classe.

Aplica-se a