Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlSchemaSet.Schemas Method (String)

Note: This method is new in the .NET Framework version 2.0.

Returns a collection of all the XML Schema definition language (XSD) schemas in the XmlSchemaSet that belong to the given namespace.

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

public ICollection Schemas (
	string targetNamespace
public ICollection Schemas (
	String targetNamespace
public function Schemas (
	targetNamespace : String
) : ICollection



The schema targetNamespace property.

Return Value

An ICollection object containing all the schemas that have been added to the XmlSchemaSet that belong to the given namespace. If no schemas have been added to the XmlSchemaSet, an empty ICollection object is returned.

If the targetNamespace parameter is a null reference (Nothing in Visual Basic) or Empty, then all schemas without a namespace are returned.

This method returns schemas that were added indirectly to the XmlSchemaSet because they were imported.


The Schemas method is the equivalent of the Item method of the obsolete XmlSchemaCollection.

The following example illustrates how to iterate over all the schemas in the http://www.contoso.com/books namespace in the XmlSchemaSet.

XmlSchemaSet schemaSet = new XmlSchemaSet();
schemaSet.Add("http://www.contoso.com/books", "http://www.contoso.com/books.xsd");

foreach (XmlSchema schema in schemaSet.Schemas("http://www.contoso.com/books"))

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

© 2015 Microsoft