XmlSchemaSet.Remove(XmlSchema) XmlSchemaSet.Remove(XmlSchema) XmlSchemaSet.Remove(XmlSchema) XmlSchemaSet.Remove(XmlSchema) Method

定义

XmlSchemaSet 移除指定的 XML 架构定义语言 (XSD) 架构。Removes the specified XML Schema definition language (XSD) schema from the XmlSchemaSet.

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 XmlSchema XmlSchema

要从 XmlSchema 中移除的 XmlSchemaSet 对象。The XmlSchema object to remove from the XmlSchemaSet.

返回

XmlSchema 中移除的 XmlSchemaSet 对象,或如果在 XmlSchemaSet 中未找到该架构,则为 nullThe XmlSchema object removed from the XmlSchemaSet or null if the schema was not found in the XmlSchemaSet.

异常

此架构不是有效的架构。The schema is not a valid schema.

作为参数传递的 XmlSchemanullThe XmlSchema passed as a parameter is null.

示例

下面的示例演示了添加到多个架构XmlSchemaSet,然后删除其中一个架构使用Remove方法。The following example illustrates adding multiple schemas to an XmlSchemaSet, then removing one of the schemas using the Remove method.

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属性设置为falseRemoving a schema from the XmlSchemaSet sets the IsCompiled property to false.

适用于