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.
var resolver = new XmlUrlResolver();
var myCred = new NetworkCredential(UserName, SecurelyStoredPassword, Domain);
resolver.Credentials = myCred;

var 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 類別來指定要在其所建立的物件中執行的功能 XmlReaderThis method uses the XmlReaderSettings class to specify which features to implement in the XmlReader object it creates.

請參閱和參考頁面的備註區段, XmlReader Create 以取得要用於一致性檢查、驗證和其他常見案例的設定資訊。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

使用類別時,請考慮下列事項 XmlReaderSettingsConsider 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.

適用於

另請參閱