Export (0) Print
Expand All

XmlReaderSettings Class

Specifies a set of features to support on the XmlReader object created by the Create method.

System.Object
  System.Xml.XmlReaderSettings

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

public sealed class XmlReaderSettings

The XmlReaderSettings type exposes the following members.

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlReaderSettings()Initializes a new instance of the XmlReaderSettings class.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360XmlReaderSettings(XmlResolver)Initializes a new instance of the XmlReaderSettings class using a XmlResolver object.
Top

  NameDescription
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CheckCharactersGets or sets a value indicating whether to do character checking.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360CloseInputGets or sets a value indicating whether the underlying stream or TextReader should be closed when the reader is closed.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360ConformanceLevelGets or sets the level of conformance which the XmlReader will comply.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360DtdProcessingGets or sets the DtdProcessing enumeration.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IgnoreCommentsGets or sets a value indicating whether to ignore comments.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IgnoreProcessingInstructionsGets or sets a value indicating whether to ignore processing instructions.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360IgnoreWhitespaceGets or sets a value indicating whether to ignore insignificant white space.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360LineNumberOffsetGets or sets line number offset of the XmlReader object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360LinePositionOffsetGets or sets line position offset of the XmlReader object.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360MaxCharactersFromEntitiesGets or sets a value indicating the maximum allowable number of characters in a document that result from expanding entities.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360MaxCharactersInDocumentGets or sets a value indicating the maximum allowable number of characters XML document. A zero (0) value means no limits on the size of the XML document. A non-zero value specifies the maximum size, in characters.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360NameTableGets or sets the XmlNameTable used for atomized string comparisons.
Public propertySupported by Silverlight for Windows PhoneSupported by Xbox 360XmlResolverSets the XmlResolver used to access external documents.
Top

  NameDescription
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360CloneCreates a copy of the XmlReaderSettings instance.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360Equals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360FinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows PhoneSupported by Xbox 360MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ResetResets the members of the settings class to their default values.
Public methodSupported by Silverlight for Windows PhoneSupported by Xbox 360ToStringReturns a string that represents the current object. (Inherited from Object.)
Top

In the .NET Framework version 2.0 release, the Create method is the preferred mechanism for obtaining XmlReader instances. The Create method uses the XmlReaderSettings class to specify which features to implement in the created XmlReader object.

Security Considerations

The following are things to consider when using the XmlReaderSettings class.

  • XmlReaderSettings objects can contain sensitive information such as user credentials. You should be careful when caching XmlReaderSettings objects, or when passing the XmlReaderSettings object from one component to another.

  • DTD processing is disabled by default. If you enable DTD processing, you need to be aware of including DTDs from untrusted sources and possible denial of service attacks.

  • Do not accept supporting components, such as NameTable, XmlNamespaceManager, and XmlResolver objects, from an untrusted source.

  • Memory usage of an application that uses XmlReader may have a correlation to the size of the parsed XML document. One form of denial of service attack is when excessively large XML documents are submitted to be parsed. You can limit the size of the document that can be parsed by setting the MaxCharactersInDocument property and then limit the number of characters that result from expanding entities by setting the MaxCharactersFromEntities property.

The following example preloads the DTDs and entities defined in XHTML 1.0 by setting Xhtml10 on the XmlPreloadedResolver. In this example, the XHTMLPage.html file is a part of the application's XAP package; therefore, we have to pass a fallback resolver to the constructor of the T:System.Xml.Resolvers.XmlPreloadedResolver.



XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
settings.XmlResolver =
    new XmlPreloadedResolver(new XmlXapResolver(),
        XmlKnownDtds.Xhtml10);

using (XmlReader reader = XmlReader.Create("HTMLPage.html", settings))
{
XDocument document = XDocument.Load(reader);
OutputTextBlock.Text = document.ToString();
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft