XmlSchemaAll Class

Represents the World Wide Web Consortium (W3C) all element (compositor).

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

public class XmlSchemaAll : XmlSchemaGroupBase
public class XmlSchemaAll extends XmlSchemaGroupBase
public class XmlSchemaAll extends XmlSchemaGroupBase
Not applicable.

The XmlSchemaAll class permits the elements in the group to appear (or not appear) in any order in the containing element.

The following example creates an all element.

using System;
using System.Xml;
using System.Xml.Schema;

public class Sample
    public static void Main()
        XmlSchema schema = new XmlSchema();

        XmlSchemaElement thing1 = new XmlSchemaElement();
        thing1.Name = "thing1";
        thing1.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        XmlSchemaElement thing2 = new XmlSchemaElement();
        thing2.Name = "thing2";
        thing2.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        XmlSchemaElement thing3 = new XmlSchemaElement();
        thing3.Name = "thing3";
        thing3.SchemaTypeName =
        new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        XmlSchemaElement thing4 = new XmlSchemaElement();
        thing4.Name = "thing4";
        thing4.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        XmlSchemaAttribute myAttribute = new XmlSchemaAttribute();
        myAttribute.Name = "myAttribute";
        myAttribute.SchemaTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema");

        XmlSchemaComplexType myComplexType = new XmlSchemaComplexType();
        myComplexType.Name = "myComplexType";

        XmlSchemaAll complexType_all = new XmlSchemaAll();

        XmlSchemaElement complexType_all_thing1 = new XmlSchemaElement();
        complexType_all_thing1.RefName = new XmlQualifiedName("thing1", "");

        XmlSchemaElement complexType_all_thing2 = new XmlSchemaElement();
        complexType_all_thing2.RefName = new XmlQualifiedName("thing2", "");

        XmlSchemaElement complexType_all_thing3 = new XmlSchemaElement();
        complexType_all_thing3.RefName = new XmlQualifiedName("thing3", "");

        XmlSchemaElement complexType_all_thing4 = new XmlSchemaElement();
        complexType_all_thing4.RefName = new XmlQualifiedName("thing4", "");

        myComplexType.Particle = complexType_all;

        XmlSchemaAttribute complexType_myAttribute = new XmlSchemaAttribute();
        complexType_myAttribute.RefName = new XmlQualifiedName("myAttribute", "");


        XmlSchemaSet schemaSet = new XmlSchemaSet();
        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
            compiledSchema = schema1;

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);

    private static void ValidationCallbackOne(object sender, ValidationEventArgs args)


The following XML file is generated for the preceding code example.

<?xml version="1.0" encoding="IBM437"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="thing1" type="xs:string"/>
  <xs:element name="thing2" type="xs:string"/>
  <xs:element name="thing3" type="xs:string"/>
  <xs:element name="thing4" type="xs:string"/>
  <xs:attribute name="myAttribute" type="xs:decimal"/>
  <xs:complexType name="myComplexType">
      <xs:element ref="thing1" />
      <xs:element ref="thing2" />
      <xs:element ref="thing3" />
      <xs:element ref="thing4" />
      <xs:attribute ref="myAttribute"/>

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions