XmlReader.HasValue XmlReader.HasValue XmlReader.HasValue XmlReader.HasValue Property

定义

当在派生类中被重写时,获取一个值,该值指示当前节点是否可以具有 ValueWhen overridden in a derived class, gets a value indicating whether the current node can have a Value.

public:
 virtual property bool HasValue { bool get(); };
public virtual bool HasValue { get; }
member this.HasValue : bool
Public Overridable ReadOnly Property HasValue As Boolean

属性值

如果读取器当前定位在的节点可以具有 Value,则为 true;否则为 falsetrue if the node on which the reader is currently positioned can have a Value; otherwise, false. 如果为 false,则节点值为 String.EmptyIf false, the node has a value of String.Empty.

异常

在上一次异步操作完成之前调用了 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."

示例

请参阅HasValue(在XmlTextReader类) 使用此方法的示例。See HasValue (in the XmlTextReader class) for a sample using this method.

注解

下表列出具有要返回的值的节点类型。The following table lists node types that have a value to return.

节点类型Node Type Value
Attribute 属性的值。The value of the attribute.
CDATA CDATA 节的内容。The content of the CDATA section.
Comment 注释的内容。The content of the comment.
DocumentType 内部子集。The internal subset.
ProcessingInstruction 全部内容(不包括指令目标)。The entire content, excluding the target.
SignificantWhitespace 混合内容模型中标记之间的空白。The white space between markup in a mixed content model.
Text 文本节点的内容。The content of the text node.
Whitespace 标记之间的空白。The white space between markup.
XmlDeclaration 声明的内容。The content of the declaration.

适用于