XmlSchemaCollection.Item[String] Właściwość

Definicja

XmlSchema Pobiera skojarzony z danym identyfikatorem URI przestrzeni nazw.

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

Parametry

ns
String

Identyfikator URI przestrzeni nazw skojarzony ze schematem, który chcesz zwrócić. Zazwyczaj będzie targetNamespace to schemat.

Wartość właściwości

Skojarzony XmlSchema z identyfikatorem URI przestrzeni nazw; null jeśli nie ma załadowanego schematu skojarzonego z daną przestrzenią nazw lub jeśli przestrzeń nazw jest skojarzona ze schematem XDR.

Przykłady

Poniższy przykład sprawdza, czy schemat znajduje się w kolekcji. Jeśli tak jest, wyświetla schemat.

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

Uwagi

Ważne

Klasa XmlSchemaCollection jest przestarzała w .NET Framework w wersji 2.0 i została zastąpiona przez klasęXmlSchemaSet.

Dotyczy