XmlReader.ReadContentAsDouble XmlReader.ReadContentAsDouble XmlReader.ReadContentAsDouble XmlReader.ReadContentAsDouble Method

定义

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

public:
 virtual double ReadContentAsDouble();
public virtual double ReadContentAsDouble ();
abstract member ReadContentAsDouble : unit -> double
override this.ReadContentAsDouble : unit -> double
Public Overridable Function ReadContentAsDouble () As Double

返回

作为双精度浮点数的文本内容。The text content as a double-precision floating-point number.

异常

试图进行的强制转换无效。The attempted cast is not valid.

该字符串格式无效。The string format is not valid.

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

注解

此方法将文本、 空白、 有效空白和 CDATA 部分中,连接,将跳过任何注释或处理指令。This method concatenates text, white space, significant white space, and CDATA sections, and skips any comments or processing instructions. 实体引用来自动解决。Entity references are automatically resolved.

如果将内容类型xsd:double,读取器返回一个双精度浮点数。If the content is typed xsd:double, the reader returns a double-precision floating-point number. 如果内容未类型化xsd:double,读取器将尝试将其转换为双精度浮点数,根据定义的规则W3C XML 架构第 2 部分:数据类型建议。If the content is not typed xsd:double, the reader attempts to convert it to a double-precision floating-point number according to the rules defined by the W3C XML Schema Part 2: Datatypes recommendation.

下表描述了此方法将每个节点类型的处理。The following table describes how this method treats each node type.

XmlNodeTypeXmlNodeType 返回值Return value 读取器行为Reader behavior
Text

CDATA

Whitespace

SignificantWhitespace

EntityReference

EndEntity
将文本、CDATA、空白和有效空白节点的串联内容转换为所请求的类型。Concatenated content of text, CDATA, white space and significant white space nodes converted to the requested type. 移至下一个开始元素或结束元素标记。Moves to the next start element or end element tag. 实体引用自动展开。Entity references are automatically expanded.
Attribute 与调用相同XmlConvert.ToXxx上属性值。Same as calling XmlConvert.ToXxx on the attribute value. 读取器仍保留在当前位置。The reader remains in the current position.
Comment

ProcessingInstruction
忽略处理指令 (PI) 或注释,读取 PI 或注释后面的串联文本内容。Ignores the processing instruction (PI) or comment and reads the concatenated text content that follows the PI or comment. 移至下一个开始元素或结束元素标记。Moves to the next start element or end element tag. 实体引用自动展开。Entity references are automatically expanded.
EndElement 空字符串。An empty string. 读取器仍保留在当前位置。The reader remains in the current position.
Element

XmlDeclaration

None

Document

DocumentType

Notation

Entity

DocumentFragment
引发 InvalidOperationExceptionAn InvalidOperationException is thrown. 未定义,尽管通常读取器将保留在当前位置。Undefined, although typically the reader remains in the current position.

有关详细信息,请参阅XmlReader参考页和W3C XML 架构第 2 部分:数据类型建议。For more information, see the XmlReader reference page and the W3C XML Schema Part 2: Datatypes recommendation.

适用于