XmlReaderSettings 类

定义

指定在由 XmlReader 方法创建的 Create 对象上支持的一组功能。Specifies a set of features to support on the XmlReader object created by the Create method.

public ref class XmlReaderSettings sealed
public sealed class XmlReaderSettings
type XmlReaderSettings = class
Public NotInheritable Class XmlReaderSettings
继承
XmlReaderSettings

示例

下面的示例创建一个XmlReader , 它将XmlUrlResolver与所需的凭据一起使用。The following example creates an XmlReader that uses an XmlUrlResolver with the necessary credentials.

// Create an XmlUrlResolver with the credentials necessary to access the Web server.
XmlUrlResolver resolver = new XmlUrlResolver();
System.Net.NetworkCredential myCred;
myCred  = new System.Net.NetworkCredential(UserName,SecurelyStoredPassword,Domain);  
resolver.Credentials = myCred;

XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = resolver;

// Create the reader.
XmlReader reader = XmlReader.Create("http://serverName/data/books.xml", settings);
' Create an XmlUrlResolver with the credentials necessary to access the Web server.
Dim resolver As New XmlUrlResolver()
Dim myCred As System.Net.NetworkCredential
myCred = New System.Net.NetworkCredential(UserName, SecurelyStoredPassword, Domain)
resolver.Credentials = myCred

Dim settings As New XmlReaderSettings()
settings.XmlResolver = resolver

' Create the reader.
Dim reader As XmlReader = XmlReader.Create("http://serverName/data/books.xml", settings)

注解

使用Create方法获取XmlReader实例。You use the Create method to obtain XmlReader instances. 此方法使用XmlReaderSettings类指定在其创建的XmlReader对象中实现哪些功能。This method uses the XmlReaderSettings class to specify which features to implement in the XmlReader object it creates.

请参阅XmlReaderCreate参考页的 "备注" 部分, 了解要用于一致性检查、验证和其他常见方案的设置。See the Remarks sections of the XmlReader and Create reference pages for information about which settings to use for conformance checks, validation, and other common scenarios. 有关默认设置的列表, 请参见构造函数。XmlReaderSettings()See the XmlReaderSettings() constructor for a list of default settings.

安全注意事项Security considerations

使用XmlReaderSettings类时, 请注意以下事项。Consider the following when using the XmlReaderSettings class.

构造函数

XmlReaderSettings()

初始化 XmlReaderSettings 类的新实例。Initializes a new instance of the XmlReaderSettings class.

XmlReaderSettings(XmlResolver)

初始化 XmlReaderSettings 类的新实例。Initializes a new instance of the XmlReaderSettings class.

属性

Async

获取或设置是否可对特定 XmlReader 实例使用异步 XmlReader 方法。Gets or sets whether asynchronous XmlReader methods can be used on a particular XmlReader instance.

CheckCharacters

获取或设置一个值,该值指示是否进行字符检查。Gets or sets a value indicating whether to do character checking.

CloseInput

获取或设置一个值,该值指示当读取器关闭时,是否应关闭基础流或 TextReaderGets or sets a value indicating whether the underlying stream or TextReader should be closed when the reader is closed.

ConformanceLevel

获取或设置 XmlReader 将遵循的一致性级别。Gets or sets the level of conformance which the XmlReader will comply.

DtdProcessing

获取或设置确定 DTD 的处理的值。Gets or sets a value that determines the processing of DTDs.

IgnoreComments

获取或设置一个值,该值指示是否忽略注释。Gets or sets a value indicating whether to ignore comments.

IgnoreProcessingInstructions

获取或设置一个值,该值指示是否忽略处理指令。Gets or sets a value indicating whether to ignore processing instructions.

IgnoreWhitespace

获取或设置一个值,该值指示是否忽略无关紧要的空白区域。Gets or sets a value indicating whether to ignore insignificant white space.

LineNumberOffset

获取或设置 XmlReader 对象的行号偏移量。Gets or sets line number offset of the XmlReader object.

LinePositionOffset

获取或设置 XmlReader 对象的行位置偏移量。Gets or sets line position offset of the XmlReader object.

MaxCharactersFromEntities

获取或设置一个值,该值指示文档中允许扩展实体产生的最大字符数。Gets or sets a value indicating the maximum allowable number of characters in a document that result from expanding entities.

MaxCharactersInDocument

获取或设置一个值,该值指明 XML 文档中所允许的最大字符数。Gets or sets a value indicating the maximum allowable number of characters in an XML document. 零 (0) 值表示对 XML 文档的大小没有限制。A zero (0) value means no limits on the size of the XML document. 非零值指定最大大小(以字符数计)。A non-zero value specifies the maximum size, in characters.

NameTable

获取或设置用于原子化字符串比较的 XmlNameTableGets or sets the XmlNameTable used for atomized string comparisons.

ProhibitDtd

获取或设置一个值,该值指示是否禁用文档类型定义 (DTD) 处理。Gets or sets a value indicating whether to prohibit document type definition (DTD) processing. 此属性已过时。This property is obsolete. 请改用 DtdProcessingUse DtdProcessing instead.

Schemas

获取或设置在执行架构验证时使用的 XmlSchemaSetGets or sets the XmlSchemaSet to use when performing schema validation.

ValidationFlags

获取或设置一个指示架构验证设置的值。Gets or sets a value indicating the schema validation settings. 此设置应用于验证架构的 XmlReader 对象(ValidationType 属性设置为 ValidationType.Schema)。This setting applies to XmlReader objects that validate schemas (ValidationType property set to ValidationType.Schema).

ValidationType

获取或设置一个值,该值指示 XmlReader 在读取时是否执行验证或类型分配。Gets or sets a value indicating whether the XmlReader will perform validation or type assignment when reading.

XmlResolver

设置用来访问外部文档的 XmlResolverSets the XmlResolver used to access external documents.

方法

Clone()

创建 XmlReaderSettings 实例的副本。Creates a copy of the XmlReaderSettings instance.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Reset()

将设置类的成员重置为各自的默认值。Resets the members of the settings class to their default values.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

事件

ValidationEventHandler

在读取器遇到验证错误时发生。Occurs when the reader encounters validation errors.

适用于

另请参阅