XmlSchemaSet.Remove(XmlSchema) Metoda

Definicja

Usuwa określony schemat języka definicji schematu XML (XSD) z programu XmlSchemaSet.

public:
 System::Xml::Schema::XmlSchema ^ Remove(System::Xml::Schema::XmlSchema ^ schema);
public System.Xml.Schema.XmlSchema? Remove (System.Xml.Schema.XmlSchema schema);
public System.Xml.Schema.XmlSchema Remove (System.Xml.Schema.XmlSchema schema);
member this.Remove : System.Xml.Schema.XmlSchema -> System.Xml.Schema.XmlSchema
Public Function Remove (schema As XmlSchema) As XmlSchema

Parametry

schema
XmlSchema

Obiekt XmlSchema do usunięcia z obiektu XmlSchemaSet.

Zwraca

Obiekt XmlSchema usunięty z XmlSchemaSet obiektu lub null , jeśli schemat nie został znaleziony w obiekcie XmlSchemaSet.

Wyjątki

Schemat nie jest prawidłowym schematem.

Przekazany XmlSchema jako parametr to null.

Przykłady

W poniższym przykładzie pokazano dodawanie wielu schematów do XmlSchemaSetobiektu , a następnie usunięcie jednego ze schematów przy użyciu Remove metody .

Dim schemaSet As XmlSchemaSet = New XmlSchemaSet()
schemaSet.Add("http://www.contoso.com/retail", "http://www.contoso.com/retail.xsd")
schemaSet.Add("http://www.contoso.com/books", "http://www.contoso.com/books.xsd")
schemaSet.Add("http://www.contoso.com/music", "http://www.contoso.com/music.xsd")

Dim schema As XmlSchema

For Each schema In schemaSet.Schemas()

    If schema.TargetNamespace = "http://www.contoso.com/music" Then
        schemaSet.Remove(schema)
    End If

Next
XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add("http://www.contoso.com/retail", "http://www.contoso.com/retail.xsd");
schemaSet.Add("http://www.contoso.com/books", "http://www.contoso.com/books.xsd");
schemaSet.Add("http://www.contoso.com/music", "http://www.contoso.com/music.xsd");

foreach (XmlSchema schema in schemaSet.Schemas())
{
    if (schema.TargetNamespace == "http://www.contoso.com/music")
    {
        schemaSet.Remove(schema);
    }
}

Uwagi

Usunięcie schematu XmlSchemaSet z właściwości ustawia IsCompiled wartość false.

Dotyczy