This documentation is archived and is not being maintained.

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

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", "");

        XmlSchemaElement thing2 = new XmlSchemaElement();
        thing2.Name = "thing2";
        thing2.SchemaTypeName = new XmlQualifiedName("string", "");

        XmlSchemaElement thing3 = new XmlSchemaElement();
        thing3.Name = "thing3";
        thing3.SchemaTypeName =
        new XmlQualifiedName("string", "");

        XmlSchemaElement thing4 = new XmlSchemaElement();
        thing4.Name = "thing4";
        thing4.SchemaTypeName = new XmlQualifiedName("string", "");

        XmlSchemaAttribute myAttribute = new XmlSchemaAttribute();
        myAttribute.Name = "myAttribute";
        myAttribute.SchemaTypeName = new XmlQualifiedName("decimal", "");

        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", "");
        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="">
  <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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0