次の方法で共有


XmlSchemaSet.Remove(XmlSchema) メソッド

定義

指定した XML スキーマ定義言語 (XSD) スキーマを 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

パラメーター

schema
XmlSchema

XmlSchemaSetから削除するXmlSchema オブジェクト。

戻り値

XmlSchemaSetから削除されたXmlSchema オブジェクト。スキーマがXmlSchemaSetで見つからなかった場合はnull

例外

スキーマが有効なスキーマではありません。

パラメーターとして渡される XmlSchemanull

次の例は、 XmlSchemaSetに複数のスキーマを追加した後、 Remove メソッドを使用していずれかのスキーマを削除する方法を示しています。

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);
    }
}

注釈

XmlSchemaSetからスキーマを削除すると、IsCompiled プロパティがfalseに設定されます。

適用対象