Export (0) Print
Expand All

XmlSchemaCollection.Add Method (XmlSchemaCollection)

Adds all the namespaces defined in the given collection (including their associated schemas) to this collection.

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

public void Add(
	XmlSchemaCollection schema


Type: System.Xml.Schema.XmlSchemaCollection

The XmlSchemaCollection you want to add to this collection.

If the schema being added contains references to other namespaces (through include and import elements or the x-schema attribute), the trust level of the application determines how these other namespaces are resolved. (In the .NET Framework version 1.0, a default XmlUrlResolver was always used).

Fully trusted code: A default XmlUrlResolver with no user credentials is used to resolve any external resources. The schemas for these other namespaces are loaded for validation purposes only. Unlike the original schema, these other schemas are not explicitly added to the schema collection. As a result, they are not accessible using any of the collection methods or properties. If these external resources are located on a network resource that requires authentication, use an overload that takes an XmlResolver as one of its arguments and specify an XmlResolver with the necessary credentials.

Semi-trusted code: External references are not resolved.


If the XmlSchemaCollection is being accessed using the XmlValidatingReader.Schemas property, the Add method uses the XmlResolver specified by the XmlValidatingReader.XmlResolver property.

Important noteImportant

The XmlSchemaCollection class is obsolete in the .NET Framework version 2.0 and has been replaced by the XmlSchemaSet class.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft