通过


XmlSchemaSet.Remove(XmlSchema) 方法

定义

XmlSchemaSet中删除指定的 XML 架构定义语言 (XSD) 架构。

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

XmlSchema 从 . XmlSchemaSet中删除的对象。

返回

XmlSchemaXmlSchemaSetnull中或未找到XmlSchemaSet架构时删除的对象。

例外

架构不是有效的架构。

XmlSchema作为参数传递的为 null.

示例

以下示例演示如何向某个 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);
    }
}

注解

将属性设置为 中删除架构。

适用于