How to remove attributes such as minOccurs from a schema using XmlSchema and XmlSchemaSet

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
Im generating a custom schema programmatically using XmlSchema and XmlSchemaSet objects but I dont know how to delete attributes such as minOccurs. Is this possible?
I can delete elements as follows:

<pre>foreach (XmlSchemaElement element in schema.Elements.Values)
{
if (element.Name.Equals("Product"))
{
schema.Items.Remove(element);
}

}[/code]
I can change elements attributes such as minOccurs as follows:<br/>


<pre>if (particle is XmlSchemaElement)
{
XmlSchemaElement element = particle as XmlSchemaElement;

element.MinOccurs = 1;
element.IsNillable = false;
}[/code]

but have no clue how to remove unwanted attributes via the XmlSchema API.
Ive used the following guide for accessing a schema programmatically:
Walking XmlSchema and XmlSchemaSet Objects
http://blogs.msdn.com/b/stan_kitsis/archive/2005/08/06/448572.aspx http://blogs.msdn.com/b/stan_kitsis/archive/2005/08/06/448572.aspx

Thanks

View the full article
 
Back
Top