XmlTextReader 类

定义

表示提供对 XML 数据进行快速、非缓存、只进访问的读取器。Represents a reader that provides fast, non-cached, forward-only access to XML data.

从 .NET Framework 2.0 开始,建议改用 XmlReader 类。Starting with the .NET Framework 2.0, we recommend that you use the XmlReader class instead.

public ref class XmlTextReader : System::Xml::XmlReader, System::Xml::IXmlLineInfo, System::Xml::IXmlNamespaceResolver
public class XmlTextReader : System.Xml.XmlReader, System.Xml.IXmlLineInfo, System.Xml.IXmlNamespaceResolver
type XmlTextReader = class
    inherit XmlReader
    interface IXmlLineInfo
    interface IXmlNamespaceResolver
Public Class XmlTextReader
Inherits XmlReader
Implements IXmlLineInfo, IXmlNamespaceResolver
继承
XmlTextReader
实现

注解

备注

从 .NET Framework 2.0 开始,我们建议使用 XmlReader.Create 方法创建 XmlReader 实例,以利用新功能。Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

XmlTextReader 提供对 XML 数据流的只进只读访问。XmlTextReader provides forward-only, read-only access to a stream of XML data. 当前节点指读取器所处的节点。The current node refers to the node on which the reader is positioned. 读取器是高级的,使用任何读取方法,属性反映当前节点的值。The reader is advanced using any of the read methods and properties reflect the value of the current node.

此类实现 XmlReader 并符合 W3C 可扩展标记语言(XML)1.0 和 XML 中的命名空间的建议。This class implements XmlReader and conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations. XmlTextReader 提供了以下功能:XmlTextReader provides the following functionality:

  • 强制执行格式正确的 XML 的规则。Enforces the rules of well-formed XML.

  • XmlTextReader 不提供数据验证。XmlTextReader does not provide data validation.

  • 检查 DocumentType 的节点是否格式正确。Checks that DocumentType nodes are well-formed. XmlTextReader 检查 DTD 的格式是否良好,但不使用 DTD 进行验证。XmlTextReader checks the DTD for well-formedness, but does not validate using the DTD.

  • 对于 XmlNodeType.EntityReferenceNodeType 的节点,将返回一个空 EntityReference 节点(即,Value 属性为 String.Empty)。For nodes where NodeType is XmlNodeType.EntityReference, a single empty EntityReference node is returned (that is, the Value property is String.Empty).

备注

DTD 中实体的实际声明称为 Entity 节点。The actual declarations of entities in the DTD are called Entity nodes. 当你在数据中引用这些节点时,它们将被称为 EntityReference 节点。When you refer to these nodes in your data, they are called EntityReference nodes.

  • 不扩展默认属性。Does not expand default attributes.

由于 XmlTextReader 不执行数据验证所需的额外检查,因此它提供了快速格式正确的分析器。Because the XmlTextReader does not perform the extra checks required for data validation, it provides a fast well-formedness parser.

若要执行数据验证,请使用验证 XmlReaderTo perform data validation, use a validating XmlReader.

若要读取 XmlDocument中的 XML 数据,请使用 XmlNodeReaderTo read XML data from an XmlDocument, use XmlNodeReader.

XmlTextReader 引发 XML 分析错误的 XmlExceptionXmlTextReader throws an XmlException on XML parse errors. 引发异常后,读取器的状态不可预测。After an exception is thrown the state of the reader is not predictable. 例如,报告的节点类型可能不同于当前节点的实际节点类型。For example, the reported node type may be different than the actual node type of the current node. 使用 ReadState 属性检查读取器是否处于错误状态。Use the ReadState property to check whether a reader is in error state.

安全注意事项Security Considerations

使用 XmlTextReader 类时,需要注意以下事项。The following are things to consider when using the XmlTextReader class.

  • 引发的异常 XmlTextReader 可能会泄露您不希望冒泡到应用程序的路径信息。Exceptions thrown the XmlTextReader can disclose path information that you do not want bubbled up to the application. 应用程序必须捕获异常并进行相应的处理。Your applications must catch exceptions and process them appropriately.

  • 默认情况下启用 DTD 处理。DTD processing is enabled by default. 如果你担心拒绝服务问题,或者如果你正在处理不受信任的源,请禁用 DTD 处理。Disable DTD processing if you are concerned about Denial of Service issues or if you are dealing with untrusted sources. DtdProcessing 属性设置为 Prohibit 以禁用 DTD 处理。Set the DtdProcessing property to Prohibit to disable DTD processing.

    如果启用了 DTD 处理,可以使用 XmlSecureResolver 限制 XmlTextReader 可以访问的资源。If you have DTD processing enabled, you can use the XmlSecureResolver to restrict the resources that the XmlTextReader can access. 还可以设计应用程序以使 XML 处理受内存和时间的约束。You can also design your application so that the XML processing is memory and time constrained. 例如,在 ASP.NET 应用程序中配置超时限制。For example, configure time-out limits in your ASP.NET application.

  • XML 数据可以包含对外部资源(如 DTD 文件)的引用。XML data can include references to external resources such as a DTD file. 默认情况下,外部资源使用没有用户凭据的 XmlUrlResolver 对象进行解析。By default external resources are resolved using an XmlUrlResolver object with no user credentials. 通过执行下列操作之一,可以使此操作更加安全:You can secure this further by doing one of the following:

  • XML 数据可以包含大量属性、命名空间声明、嵌套元素等,需要大量的时间来处理。XML data can contain a large number of attributes, namespace declarations, nested elements and so on that require a substantial amount of time to process. 若要限制发送到 XmlTextReader的输入的大小,请创建一个自定义的 IStream 实现并向其提供 XmlTextReaderTo limit the size of the input that is sent to the XmlTextReader, create a custom IStream implementation and supply it the XmlTextReader.

  • ReadValueChunk 方法可用于处理大型数据流。The ReadValueChunk method can be used to handle large streams of data. 此方法一次读取少量的字符,而不是为整个值分配单个字符串。This method reads a small number of characters at a time instead of allocating a single string for the whole value.

  • 默认情况下不展开常规实体。By default general entities are not expanded. 常规实体在调用 ResolveEntity 方法时展开。General entities are expanded when you call the ResolveEntity method.

继承者说明

此类具有继承要求。This class has an inheritance demand. XmlTextReader继承需要完全信任。Full trust is required to inherit from XmlTextReader.

构造函数

XmlTextReader()

初始化 XmlTextReader 的新实例。Initializes a new instance of the XmlTextReader.

XmlTextReader(Stream)

使用指定的流初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified stream.

XmlTextReader(Stream, XmlNameTable)

用指定的流和 XmlNameTable 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified stream and XmlNameTable.

XmlTextReader(Stream, XmlNodeType, XmlParserContext)

用指定的流、XmlNodeTypeXmlParserContext 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified stream, XmlNodeType, and XmlParserContext.

XmlTextReader(String)

用指定的文件初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified file.

XmlTextReader(String, Stream)

使用指定的 URL 和流初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified URL and stream.

XmlTextReader(String, Stream, XmlNameTable)

使用指定的 URL、流和 XmlNameTable 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified URL, stream and XmlNameTable.

XmlTextReader(String, TextReader)

使用指定的 URL 和 TextReader 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified URL and TextReader.

XmlTextReader(String, TextReader, XmlNameTable)

使用指定的 URL、TextReaderXmlNameTable 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified URL, TextReader and XmlNameTable.

XmlTextReader(String, XmlNameTable)

使用指定的文件和 XmlNameTable 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified file and XmlNameTable.

XmlTextReader(String, XmlNodeType, XmlParserContext)

使用指定的字符串、XmlNodeTypeXmlParserContext 初始化 XmlTextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified string, XmlNodeType, and XmlParserContext.

XmlTextReader(TextReader)

使用指定的 XmlTextReader 初始化 TextReader 类的新实例。Initializes a new instance of the XmlTextReader class with the specified TextReader.

XmlTextReader(TextReader, XmlNameTable)

使用指定的 XmlTextReaderTextReader 初始化 XmlNameTable 类的新实例。Initializes a new instance of the XmlTextReader class with the specified TextReader and XmlNameTable.

XmlTextReader(XmlNameTable)

使用指定的 XmlTextReader 初始化 XmlNameTable 类的新实例。Initializes a new instance of the XmlTextReader class with the specified XmlNameTable.

属性

AttributeCount

获取当前节点上的属性数目。Gets the number of attributes on the current node.

BaseURI

获取当前节点的基 URI。Gets the base URI of the current node.

CanReadBinaryContent

获取一个值,该值指示 XmlTextReader 是否实现二进制内容读取方法。Gets a value indicating whether the XmlTextReader implements the binary content read methods.

CanReadValueChunk

获取一个值,该值指示 XmlTextReader 是否实现 ReadValueChunk(Char[], Int32, Int32) 方法。Gets a value indicating whether the XmlTextReader implements the ReadValueChunk(Char[], Int32, Int32) method.

CanResolveEntity

获取一个值,该值指示此读取器是否可以分析和解析实体。Gets a value indicating whether this reader can parse and resolve entities.

Depth

获取 XML 文档中当前节点的深度。Gets the depth of the current node in the XML document.

DtdProcessing

获取或设置 DtdProcessing 枚举。Gets or sets the DtdProcessing enumeration.

Encoding

获取文档的编码。Gets the encoding of the document.

EntityHandling

获取或设置一个值,该值指定读取器处理实体的方式。Gets or sets a value that specifies how the reader handles entities.

EOF

获取一个值,该值指示读取器是否定位在流结尾。Gets a value indicating whether the reader is positioned at the end of the stream.

HasAttributes

获取一个值,该值指示当前节点是否有任何属性。Gets a value indicating whether the current node has any attributes.

(继承自 XmlReader)
HasValue

获取一个值,该值指示当前节点是否可以具有 String.Empty 以外的 ValueGets a value indicating whether the current node can have a Value other than String.Empty.

IsDefault

获取一个值,该值指示当前节点是否是从 DTD 或架构中定义的默认值生成的属性。Gets a value indicating whether the current node is an attribute that was generated from the default value defined in the DTD or schema.

IsEmptyElement

获取一个值,该值指示当前节点是否为空元素(例如 <MyElement/>)。Gets a value indicating whether the current node is an empty element (for example, <MyElement/>).

Item[Int32]

获取具有指定索引的属性的值。Gets the value of the attribute with the specified index.

Item[String, String]

获取具有指定本地名称和命名空间 URI 的属性的值。Gets the value of the attribute with the specified local name and namespace URI.

Item[String]

获取具有指定名称的属性的值。Gets the value of the attribute with the specified name.

LineNumber

获取当前行号。Gets the current line number.

LinePosition

获取当前行位置。Gets the current line position.

LocalName

获取当前节点的本地名称。Gets the local name of the current node.

Name

获取当前节点的限定名称。Gets the qualified name of the current node.

Namespaces

获取或设置一个值,该值指示是否进行命名空间支持。Gets or sets a value indicating whether to do namespace support.

NamespaceURI

获取读取器定位在的节点的命名空间 URI(采用 W3C 命名空间规范中定义)。Gets the namespace URI (as defined in the W3C Namespace specification) of the node on which the reader is positioned.

NameTable

获取与此实现关联的 XmlNameTableGets the XmlNameTable associated with this implementation.

NodeType

获取当前节点的类型。Gets the type of the current node.

Normalization

获取或设置一个值,该值指示是否规范化空白区域和属性值。Gets or sets a value indicating whether to normalize white space and attribute values.

Prefix

获取与当前节点关联的命名空间前缀。Gets the namespace prefix associated with the current node.

ProhibitDtd

获取或设置一个值,该值指示是否允许 DTD 处理。Gets or sets a value indicating whether to allow DTD processing. 此属性已过时。This property is obsolete. 请改用 DtdProcessingUse DtdProcessing instead.

QuoteChar

获取用于括起属性节点的值的引号字符。Gets the quotation mark character used to enclose the value of an attribute node.

ReadState

获取读取器的状态。Gets the state of the reader.

SchemaInfo

获取作为架构验证结果分配给当前节点的架构信息。Gets the schema information that has been assigned to the current node as a result of schema validation.

(继承自 XmlReader)
Settings

获取用于创建此 XmlTextReader 实例的 XmlReaderSettings 对象。Gets the XmlReaderSettings object used to create this XmlTextReader instance.

Value

获取当前节点的文本值。Gets the text value of the current node.

ValueType

获取当前节点的公共语言运行时 (CLR) 类型。Gets The Common Language Runtime (CLR) type for the current node.

(继承自 XmlReader)
WhitespaceHandling

获取或设置一个值,该值指定如何处理空白区域。Gets or sets a value that specifies how white space is handled.

XmlLang

获取当前 xml:lang 范围。Gets the current xml:lang scope.

XmlResolver

设置用于解析 DTD 引用的 XmlResolverSets the XmlResolver used for resolving DTD references.

XmlSpace

获取当前 xml:space 范围。Gets the current xml:space scope.

方法

Close()

ReadState 改为 ClosedChanges the ReadState to Closed.

Dispose()

释放 XmlReader 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the XmlReader class.

(继承自 XmlReader)
Dispose(Boolean)

释放由 XmlReader 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the XmlReader and optionally releases the managed resources.

(继承自 XmlReader)
Equals(Object)

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

(继承自 Object)
GetAttribute(Int32)

获取具有指定索引的属性的值。Gets the value of the attribute with the specified index.

GetAttribute(String)

获取具有指定名称的属性的值。Gets the value of the attribute with the specified name.

GetAttribute(String, String)

获取具有指定本地名称和命名空间 URI 的属性的值。Gets the value of the attribute with the specified local name and namespace URI.

GetHashCode()

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

(继承自 Object)
GetNamespacesInScope(XmlNamespaceScope)

获取一个集合,该集合包含当前在范围内的所有命名空间。Gets a collection that contains all namespaces currently in-scope.

GetRemainder()

获取已缓冲的 XML 的剩余部分。Gets the remainder of the buffered XML.

GetType()

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

(继承自 Object)
GetValueAsync()

异步获取当前节点的值。Asynchronously gets the value of the current node.

(继承自 XmlReader)
HasLineInfo()

获取一个值,该值指示该类是否可返回行信息。Gets a value indicating whether the class can return line information.

IsStartElement()

调用 MoveToContent() 并测试当前内容节点是否是开始标记或空元素标记。Calls MoveToContent() and tests if the current content node is a start tag or empty element tag.

(继承自 XmlReader)
IsStartElement(String)

调用 MoveToContent() 并测试当前内容节点是否是开始标记或空元素标记,以及所找到元素的 Name 属性是否与给定的参数匹配。Calls MoveToContent() and tests if the current content node is a start tag or empty element tag and if the Name property of the element found matches the given argument.

(继承自 XmlReader)
IsStartElement(String, String)

调用 MoveToContent() 并测试当前内容节点是否是开始标记或空元素标记,以及所找到元素的 LocalNameNamespaceURI 属性是否与给定的字符串匹配。Calls MoveToContent() and tests if the current content node is a start tag or empty element tag and if the LocalName and NamespaceURI properties of the element found match the given strings.

(继承自 XmlReader)
LookupNamespace(String)

解析当前元素的范围内的命名空间前缀。Resolves a namespace prefix in the current element's scope.

MemberwiseClone()

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

(继承自 Object)
MoveToAttribute(Int32)

移动到具有指定索引的属性。Moves to the attribute with the specified index.

MoveToAttribute(String)

移动到具有指定名称的属性。Moves to the attribute with the specified name.

MoveToAttribute(String, String)

移动到具有指定本地名称和命名空间 URI 的属性。Moves to the attribute with the specified local name and namespace URI.

MoveToContent()

检查当前节点是否是内容(非空白文本、CDATAElementEndElementEntityReferenceEndEntity)节点。Checks whether the current node is a content (non-white space text, CDATA, Element, EndElement, EntityReference, or EndEntity) node. 如果此节点不是内容节点,则读取器向前跳至下一个内容节点或文件结尾。If the node is not a content node, the reader skips ahead to the next content node or end of file. 它跳过以下类型的节点:ProcessingInstructionDocumentTypeCommentWhitespaceSignificantWhitespaceIt skips over nodes of the following type: ProcessingInstruction, DocumentType, Comment, Whitespace, or SignificantWhitespace.

(继承自 XmlReader)
MoveToContentAsync()

异步检查当前节点是否为内容节点。Asynchronously checks whether the current node is a content node. 如果此节点不是内容节点,则读取器向前跳至下一个内容节点或文件结尾。If the node is not a content node, the reader skips ahead to the next content node or end of file.

(继承自 XmlReader)
MoveToElement()

移动到包含当前属性节点的元素。Moves to the element that contains the current attribute node.

MoveToFirstAttribute()

移动到第一个属性。Moves to the first attribute.

MoveToNextAttribute()

移动到下一个属性。Moves to the next attribute.

Read()

从流中读取下一个节点。Reads the next node from the stream.

ReadAsync()

异步读取该流的下一个节点。Asynchronously reads the next node from the stream.

(继承自 XmlReader)
ReadAttributeValue()

将属性值分析为一个或多个 TextEntityReferenceEndEntity 节点。Parses the attribute value into one or more Text, EntityReference, or EndEntity nodes.

ReadBase64(Byte[], Int32, Int32)

对 Base64 进行解码并返回解码的二进制字节。Decodes Base64 and returns the decoded binary bytes.

ReadBinHex(Byte[], Int32, Int32)

BinHex 进行解码并返回解码后的二进制字节。Decodes BinHex and returns the decoded binary bytes.

ReadChars(Char[], Int32, Int32)

将元素的文本内容读入字符缓冲区。Reads the text contents of an element into a character buffer. 通过连续调用此方法,可以读取大的嵌入文本的流。This method is designed to read large streams of embedded text by calling it successively.

ReadContentAs(Type, IXmlNamespaceResolver)

将内容作为指定类型的对象读取。Reads the content as an object of the type specified.

(继承自 XmlReader)
ReadContentAsAsync(Type, IXmlNamespaceResolver)

将内容作为指定类型的对象异步读取。Asynchronously reads the content as an object of the type specified.

(继承自 XmlReader)
ReadContentAsBase64(Byte[], Int32, Int32)

读取内容并返回 Base64 解码的二进制字节。Reads the content and returns the Base64 decoded binary bytes.

ReadContentAsBase64Async(Byte[], Int32, Int32)

异步读取内容并返回 Base64 解码的二进制字节。Asynchronously reads the content and returns the Base64 decoded binary bytes.

(继承自 XmlReader)
ReadContentAsBinHex(Byte[], Int32, Int32)

读取内容并返回 BinHex 解码的二进制字节。Reads the content and returns the BinHex decoded binary bytes.

ReadContentAsBinHexAsync(Byte[], Int32, Int32)

异步读取内容并返回 BinHex 解码的二进制字节。Asynchronously reads the content and returns the BinHex decoded binary bytes.

(继承自 XmlReader)
ReadContentAsBoolean()

将当前位置的文本内容作为 Boolean 读取。Reads the text content at the current position as a Boolean.

(继承自 XmlReader)
ReadContentAsDateTime()

将当前位置的文本内容作为 DateTime 对象读取。Reads the text content at the current position as a DateTime object.

(继承自 XmlReader)
ReadContentAsDateTimeOffset()

将当前位置的文本内容作为 DateTimeOffset 对象读取。Reads the text content at the current position as a DateTimeOffset object.

(继承自 XmlReader)
ReadContentAsDecimal()

将当前位置的文本内容作为 Decimal 对象读取。Reads the text content at the current position as a Decimal object.

(继承自 XmlReader)
ReadContentAsDouble()

将当前位置的文本内容作为双精度浮点数读取。Reads the text content at the current position as a double-precision floating-point number.

(继承自 XmlReader)
ReadContentAsFloat()

将当前位置的文本内容作为单精度浮点数读取。Reads the text content at the current position as a single-precision floating point number.

(继承自 XmlReader)
ReadContentAsInt()

将当前位置的文本内容作为 32 位有符号整数读取。Reads the text content at the current position as a 32-bit signed integer.

(继承自 XmlReader)
ReadContentAsLong()

将当前位置的文本内容作为 64 位有符号整数读取。Reads the text content at the current position as a 64-bit signed integer.

(继承自 XmlReader)
ReadContentAsObject()

将当前位置的文本内容作为 Object 读取。Reads the text content at the current position as an Object.

(继承自 XmlReader)
ReadContentAsObjectAsync()

将当前位置的文本内容作为 Object 对象异步读取。Asynchronously reads the text content at the current position as an Object.

(继承自 XmlReader)
ReadContentAsString()

将当前位置的文本内容作为 String 对象读取。Reads the text content at the current position as a String object.

(继承自 XmlReader)
ReadContentAsStringAsync()

将当前位置的文本内容作为 String 对象异步读取。Asynchronously reads the text content at the current position as a String object.

(继承自 XmlReader)
ReadElementContentAs(Type, IXmlNamespaceResolver)

将元素内容作为请求类型读取。Reads the element content as the requested type.

(继承自 XmlReader)
ReadElementContentAs(Type, IXmlNamespaceResolver, String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后将元素内容作为请求类型读取。Checks that the specified local name and namespace URI matches that of the current element, then reads the element content as the requested type.

(继承自 XmlReader)
ReadElementContentAsAsync(Type, IXmlNamespaceResolver)

将元素内容作为请求类型异步读取。Asynchronously reads the element content as the requested type.

(继承自 XmlReader)
ReadElementContentAsBase64(Byte[], Int32, Int32)

读取元素并对 Base64 内容进行解码。Reads the element and decodes the Base64 content.

ReadElementContentAsBase64Async(Byte[], Int32, Int32)

异步读取元素并对 Base64 内容进行解码。Asynchronously reads the element and decodes the Base64 content.

(继承自 XmlReader)
ReadElementContentAsBinHex(Byte[], Int32, Int32)

读取元素并对 BinHex 内容进行解码。Reads the element and decodes the BinHex content.

ReadElementContentAsBinHexAsync(Byte[], Int32, Int32)

异步读取元素并对 BinHex 内容进行解码。Asynchronously reads the element and decodes the BinHex content.

(继承自 XmlReader)
ReadElementContentAsBoolean()

读取当前元素并将内容作为 Boolean 对象返回。Reads the current element and returns the contents as a Boolean object.

(继承自 XmlReader)
ReadElementContentAsBoolean(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 Boolean 对象返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a Boolean object.

(继承自 XmlReader)
ReadElementContentAsDateTime()

读取当前元素并将内容作为 DateTime 对象返回。Reads the current element and returns the contents as a DateTime object.

(继承自 XmlReader)
ReadElementContentAsDateTime(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 DateTime 对象返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a DateTime object.

(继承自 XmlReader)
ReadElementContentAsDecimal()

读取当前元素并将内容作为 Decimal 对象返回。Reads the current element and returns the contents as a Decimal object.

(继承自 XmlReader)
ReadElementContentAsDecimal(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 Decimal 对象返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a Decimal object.

(继承自 XmlReader)
ReadElementContentAsDouble()

读取当前元素并将内容作为双精度浮点数返回。Reads the current element and returns the contents as a double-precision floating-point number.

(继承自 XmlReader)
ReadElementContentAsDouble(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为双精度浮点数返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a double-precision floating-point number.

(继承自 XmlReader)
ReadElementContentAsFloat()

读取当前元素并将内容作为单精度浮点数返回。Reads the current element and returns the contents as single-precision floating-point number.

(继承自 XmlReader)
ReadElementContentAsFloat(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为单精度浮点数返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a single-precision floating-point number.

(继承自 XmlReader)
ReadElementContentAsInt()

读取当前元素并将内容作为 32 位有符号整数返回。Reads the current element and returns the contents as a 32-bit signed integer.

(继承自 XmlReader)
ReadElementContentAsInt(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 32 位有符号整数返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a 32-bit signed integer.

(继承自 XmlReader)
ReadElementContentAsLong()

读取当前元素并将内容作为 64 位有符号整数返回。Reads the current element and returns the contents as a 64-bit signed integer.

(继承自 XmlReader)
ReadElementContentAsLong(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 64 位有符号整数返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a 64-bit signed integer.

(继承自 XmlReader)
ReadElementContentAsObject()

读取当前元素并将内容作为 Object 返回。Reads the current element and returns the contents as an Object.

(继承自 XmlReader)
ReadElementContentAsObject(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 Object 返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as an Object.

(继承自 XmlReader)
ReadElementContentAsObjectAsync()

异步读取当前元素并将内容作为 Object 返回。Asynchronously reads the current element and returns the contents as an Object.

(继承自 XmlReader)
ReadElementContentAsString()

读取当前元素并将内容作为 String 对象返回。Reads the current element and returns the contents as a String object.

(继承自 XmlReader)
ReadElementContentAsString(String, String)

检查指定的本地名称和命名空间 URI 与当前元素的本地名称和命名空间 URI 是否匹配,然后读取当前元素,并将内容作为 String 对象返回。Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a String object.

(继承自 XmlReader)
ReadElementContentAsStringAsync()

异步读取当前元素并将内容作为 String 对象返回。Asynchronously reads the current element and returns the contents as a String object.

(继承自 XmlReader)
ReadElementString()

读取纯文本元素。Reads a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

(继承自 XmlReader)
ReadElementString(String)

在读取纯文本元素之前,检查所找到元素的 Name 属性是否与给定的字符串匹配。Checks that the Name property of the element found matches the given string before reading a text-only element. 但是,建议改用 ReadElementContentAsString() 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.

(继承自 XmlReader)
ReadElementString(String, String)

在读取纯文本元素之前,检查所找到元素的 LocalNameNamespaceURI 属性是否与给定的字符串匹配。Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element. 但是,建议改用 ReadElementContentAsString(String, String) 方法,因为该方法可以更直接地处理此操作。However, we recommend that you use the ReadElementContentAsString(String, String) method instead, because it provides a more straightforward way to handle this operation.

(继承自 XmlReader)
ReadEndElement()

检查当前内容节点是否为结束标记并将读取器推进到下一个节点。Checks that the current content node is an end tag and advances the reader to the next node.

(继承自 XmlReader)
ReadInnerXml()

当在派生类中被重写时,将所有内容(包括标记)当做字符串读取。When overridden in a derived class, reads all the content, including markup, as a string.

(继承自 XmlReader)
ReadInnerXmlAsync()

异步读取所有内容,包括作为字符串的标记。Asynchronously reads all the content, including markup, as a string.

(继承自 XmlReader)
ReadOuterXml()

当在派生类中被重写时,读取表示该节点和所有它的子级的内容(包括标记)。When overridden in a derived class, reads the content, including markup, representing this node and all its children.

(继承自 XmlReader)
ReadOuterXmlAsync()

异步读取包含该节点和所有它的子级的内容(包括标记)。Asynchronously reads the content, including markup, representing this node and all its children.

(继承自 XmlReader)
ReadStartElement()

检查当前节点是否为元素并将读取器推进到下一个节点。Checks that the current node is an element and advances the reader to the next node.

(继承自 XmlReader)
ReadStartElement(String)

检查当前内容节点是否为具有给定 Name 的元素并将读取器推进到下一个节点。Checks that the current content node is an element with the given Name and advances the reader to the next node.

(继承自 XmlReader)
ReadStartElement(String, String)

检查当前内容节点是否为具有给定 LocalNameNamespaceURI 的元素并将读取器推进到下一个节点。Checks that the current content node is an element with the given LocalName and NamespaceURI and advances the reader to the next node.

(继承自 XmlReader)
ReadString()

将元素或文本节点的内容读取为一个字符串。Reads the contents of an element or a text node as a string.

ReadSubtree()

返回新的 XmlReader 实例,此实例可用于读取当前节点及其所有子节点。Returns a new XmlReader instance that can be used to read the current node, and all its descendants.

(继承自 XmlReader)
ReadToDescendant(String)

XmlReader 前进到下一个具有指定限定名的子代元素。Advances the XmlReader to the next descendant element with the specified qualified name.

(继承自 XmlReader)
ReadToDescendant(String, String)

XmlReader 前进到下一个具有指定的本地名称和命名空间 URI 的子代元素。Advances the XmlReader to the next descendant element with the specified local name and namespace URI.

(继承自 XmlReader)
ReadToFollowing(String)

一直读取,直到找到具有指定限定名的元素。Reads until an element with the specified qualified name is found.

(继承自 XmlReader)
ReadToFollowing(String, String)

一直读取,直到找到具有指定的本地名称和命名空间 URI 的元素。Reads until an element with the specified local name and namespace URI is found.

(继承自 XmlReader)
ReadToNextSibling(String)

XmlReader 前进到下一个具有指定限定名的同级元素。Advances the XmlReader to the next sibling element with the specified qualified name.

(继承自 XmlReader)
ReadToNextSibling(String, String)

XmlReader 推进到具有指定的本地名称和命名空间 URI 的下一个同级元素。Advances the XmlReader to the next sibling element with the specified local name and namespace URI.

(继承自 XmlReader)
ReadValueChunk(Char[], Int32, Int32)

读取嵌入在 XML 文档中的大量文本流。Reads large streams of text embedded in an XML document.

(继承自 XmlReader)
ReadValueChunkAsync(Char[], Int32, Int32)

异步读取嵌入在 XML 文档中的大量文本流。Asynchronously reads large streams of text embedded in an XML document.

(继承自 XmlReader)
ResetState()

将读取器的状态重置为 ReadState.Initial。Resets the state of the reader to ReadState.Initial.

ResolveEntity()

解析 EntityReference 节点的实体引用。Resolves the entity reference for EntityReference nodes.

Skip()

跳过当前节点的子级。Skips the children of the current node.

SkipAsync()

异步跳过当前节点的子级。Asynchronously skips the children of the current node.

(继承自 XmlReader)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式接口实现

IDisposable.Dispose()

有关此成员的说明,请参见 Dispose()For a description of this member, see Dispose().

(继承自 XmlReader)
IXmlLineInfo.HasLineInfo()

有关此成员的说明,请参见 HasLineInfo()For a description of this member, see HasLineInfo().

IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope)

有关此成员的说明,请参见 GetNamespacesInScope(XmlNamespaceScope)For a description of this member, see GetNamespacesInScope(XmlNamespaceScope).

IXmlNamespaceResolver.LookupNamespace(String)

有关此成员的说明,请参见 LookupNamespace(String)For a description of this member, see LookupNamespace(String).

IXmlNamespaceResolver.LookupPrefix(String)

有关此成员的说明,请参见 LookupPrefix(String)For a description of this member, see LookupPrefix(String).

适用于

另请参阅