XmlSchemaCollection.Item[String] Propiedad

Definición

Obtiene el XmlSchema asociado al URI del espacio de nombres especificado.

C#
public System.Xml.Schema.XmlSchema? this[string? ns] { get; }
C#
public System.Xml.Schema.XmlSchema this[string ns] { get; }

Parámetros

ns
String

URI del espacio de nombres asociado al esquema que desea que se devuelva. Normalmente será el targetNamespace del esquema.

Valor de propiedad

XmlSchema asociado al URI del espacio de nombres; null si no se ha cargado ningún esquema asociado al espacio de nombres especificado o si el espacio de nombres está asociado a un esquema XDR.

Ejemplos

En el ejemplo siguiente se comprueba si un esquema está en la colección. Si es así, muestra el esquema.

C#
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());
}

Comentarios

Importante

La XmlSchemaCollection clase está obsoleta en .NET Framework versión 2.0 y se ha reemplazado por la XmlSchemaSet clase .

Se aplica a

Producto Versiones
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1