XmlSchemaSet.RemoveRecursive Method

Removes the specified XML Schema definition language (XSD) schema and all the schemas it imports from the XmlSchemaSet.

Namespace: System.Xml.Schema
Assembly: System.Xml (in system.xml.dll)

public bool RemoveRecursive (
	XmlSchema schemaToRemove
)
public boolean RemoveRecursive (
	XmlSchema schemaToRemove
)
public function RemoveRecursive (
	schemaToRemove : XmlSchema
) : boolean
Not applicable.

Parameters

schemaToRemove

The XmlSchema object to remove from the XmlSchemaSet.

Return Value

Returns true if the XmlSchema object and all its imports were successfully removed; otherwise, false.

Exception typeCondition

ArgumentNullException

The XmlSchema passed as a parameter is a null reference (Nothing in Visual Basic).

Removes the specified schema and all the schemas it imports from the XmlSchemaSet, as long as there are no dependencies on the schema or its imported schemas. If there are dependencies on the schema or its imported schemas in the XmlSchemaSet, nothing is removed and RemoveRecursive returns false. If false is returned and a ValidationEventHandler is defined, a warning is sent to the event handler describing the dependencies.

The RemoveRecursive method has no effect on the state of the IsCompiled property.

The following code example illustrates adding multiple schemas to an XmlSchemaSet, then removing one of the schemas and all the schemas it imports using the RemoveRecursive method.

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.RemoveRecursive(schema);
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show: