XmlSchemaSet mySchemaSet = new XmlSchemaSet(); mySchemaSet.Add("http://example.com/myschema.xsd", "myschema.xsd"); // Adding a schema mySchemaSet.RemoveRecursive("http://example.com/myschema.xsd"); // Removing schema and its dependencies recursively
XmlSchemaSet schemaSet = new XmlSchemaSet(); schemaSet.AddSchema(schemaWithIncludeAndImport); schemaSet.Compile(); // Check validation errors and add any errors to a list ListIn this example, we create an `XmlSchemaSet` object, add an XML schema to it with includes and imports, compile the schema set, and validate it for errors. If there are no errors, we remove the schema and its dependent schemas recursively using the `RemoveRecursive` method. The package library for this class is `System.Xml`.validationErrors = new List (); foreach(XmlSchema schema in schemaSet.Schemas()) { schema.ValidationEventHandler += (object sender, ValidationEventArgs e) => { validationErrors.Add(e.Message); }; } if(validationErrors.Count == 0) { // There are no errors, remove schema schemaSet.RemoveRecursive(schemaWithIncludeAndImport); }