Gets or sets the level of conformance which the XmlReader will comply.
Assembly: System.Xml (in System.Xml.dll)
Public Property ConformanceLevel As ConformanceLevel Get Set
public ConformanceLevel ConformanceLevel { get; set; }
public: property ConformanceLevel ConformanceLevel { ConformanceLevel get (); void set (ConformanceLevel value); }
member ConformanceLevel : ConformanceLevel with get, set
Property Value
Type: System.Xml.ConformanceLevelOne 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.
Dim xmlFrag As String = "<item rk:ID='abc-23'>hammer</item> " & _ "<item rk:ID='r2-435'>paint</item>" & _ "<item rk:ID='abc-39'>saw</item>" ' Create the XmlNamespaceManager. Dim nt As New NameTable() Dim nsmgr As New XmlNamespaceManager(nt) nsmgr.AddNamespace("rk", "urn:store-items") ' Create the XmlParserContext. Dim context As New XmlParserContext(Nothing, nsmgr, Nothing, XmlSpace.None) ' Create the reader. Dim settings As New XmlReaderSettings() settings.ConformanceLevel = ConformanceLevel.Fragment Dim reader As XmlReader = XmlReader.Create(New StringReader(xmlFrag), settings, context)
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);
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Portable Class Library
Supported in: Portable Class LibraryWindows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.