This documentation is archived and is not being maintained.

XmlReaderSettings.ConformanceLevel Property

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

Gets or sets the level of conformance which the XmlReader will comply.

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

public ConformanceLevel ConformanceLevel { get; set; }
/** @property */
public ConformanceLevel get_ConformanceLevel ()

/** @property */
public void set_ConformanceLevel (ConformanceLevel value)

public function get ConformanceLevel () : ConformanceLevel

public function set ConformanceLevel (value : ConformanceLevel)

Property Value

One of the ConformanceLevel values. The default is ConformanceLevel.Document.

Note that XmlReader objects created by the Create method are more compliant by default than the XmlTextReader class. The following are conformance improvements that are not enabled on XmlTextReader, but are available by default on readers created by the Create method:

  • New lines and attribute value are normalized according to the XML spec.

  • All entities are automatically expanded.

  • Default attributes declared in the document type definition are always added even when the reader does not validate.

  • Declaration of xml prefix mapped to the correct XML namespace URI is allowed.

  • The notation names in a single NotationType attribute declaration, as well as the NmTokens in a single Enumeration attribute declaration, must all be distinct.

For more information, see Data Conformance Checking with XmlReader.

The following example creates an XmlReader object that reads an XML fragment.

string xmlFrag ="<item rk:ID='abc-23'>hammer</item> " +
                        "<item rk:ID='r2-435'>paint</item>" +
                        "<item rk:ID='abc-39'>saw</item>";

// Create the XmlNamespaceManager.
NameTable nt = new NameTable();
XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
nsmgr.AddNamespace("rk", "urn:store-items");

// Create the XmlParserContext.
XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);

// Create the reader. 
XmlReaderSettings settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Fragment;
XmlReader reader = XmlReader.Create(new StringReader(xmlFrag), settings, context);

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