XmlNodeReader XmlNodeReader XmlNodeReader XmlNodeReader Class

定义

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

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

示例

在以下示例中,XML 文件加载到 XML 文档中并进行修改。In the following example, an XML file is loaded into an XML document and modified. XML 文档传递给 XmlNodeReader,后者再传递给 XmlReader.Create 方法。The XML document is passed to an XmlNodeReader, which is then passed to the XmlReader.Create method. 在验证读取器分析文件时,可以验证对 XML 文件所作的任何更改。When the validating reader parses the file, it can validate any changes made to the XML file.

using System;
using System.Xml;
using System.Xml.Schema;
using System.IO;

public class Sample {

  public static void Main() {

    // Create and load the XML document.
    XmlDocument doc = new XmlDocument();
    doc.Load("booksSchema.xml");

    // Make changes to the document.
    XmlElement book = (XmlElement) doc.DocumentElement.FirstChild;
    book.SetAttribute("publisher", "Worldwide Publishing");

    // Create an XmlNodeReader using the XML document.
    XmlNodeReader nodeReader = new XmlNodeReader(doc);

    // Set the validation settings on the XmlReaderSettings object.
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.ValidationType = ValidationType.Schema;
    settings.Schemas.Add("urn:bookstore-schema", "books.xsd");
    settings.ValidationEventHandler += new ValidationEventHandler (ValidationCallBack);

   // Create a validating reader that wraps the XmlNodeReader object.
   XmlReader reader = XmlReader.Create(nodeReader, settings);
    
   // Parse the XML file.
   while (reader.Read());
  }

  // Display any validation errors.
  private static void ValidationCallBack(object sender, ValidationEventArgs e) {
    Console.WriteLine("Validation Error: {0}", e.Message);
  }
}
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO

public class Sample 

  public shared sub Main() 

    ' Create and load the XML document.
    Dim doc as XmlDocument = new XmlDocument()
    doc.Load("booksSchema.xml")

    ' Make changes to the document.
    Dim book as XmlElement
    book = CType(doc.DocumentElement.FirstChild, XmlElement)
    book.SetAttribute("publisher", "Worldwide Publishing")

    ' Create an XmlNodeReader using the XML document.
    Dim nodeReader as XmlNodeReader = new XmlNodeReader(doc)

    ' Set the validation settings on the XmlReaderSettings object.
    Dim settings as XmlReaderSettings = new XmlReaderSettings()
    settings.ValidationType = ValidationType.Schema
    settings.Schemas.Add("urn:bookstore-schema", "books.xsd")
    AddHandler settings.ValidationEventHandler, AddressOf ValidationCallBack

    ' Create a validating reader that wraps the XmlNodeReader object.
    Dim reader as XmlReader = XmlReader.Create(nodeReader,settings)
    
    ' Parse the XML file.
    while (reader.Read())
    end while
  end sub

  ' Display any validation errors.
  private shared sub ValidationCallBack(sender as object, e as ValidationEventArgs)
    Console.WriteLine("Validation Error: {0}", e.Message)
  end sub

end class

输入Input

下列文件作为输入使用。The following files are used as input.

bookSchema.xmlbookSchema.xml

<?xml version='1.0'?>
<bookstore xmlns="urn:bookstore-schema">
  <book genre="autobiography">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="novel">
    <title>The Confidence Man</title>
    <author>
      <first-name>Herman</first-name>
      <last-name>Melville</last-name>
    </author>
    <price>11.99</price>
  </book>
</bookstore>

books.xsdbooks.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns="urn:bookstore-schema"
    elementFormDefault="qualified"
    targetNamespace="urn:bookstore-schema">

 <xsd:element name="bookstore" type="bookstoreType"/>

 <xsd:complexType name="bookstoreType">
  <xsd:sequence maxOccurs="unbounded">
   <xsd:element name="book"  type="bookType"/>
  </xsd:sequence>
 </xsd:complexType>

 <xsd:complexType name="bookType">
  <xsd:sequence>
   <xsd:element name="title" type="xsd:string"/>
   <xsd:element name="author" type="authorName"/>
   <xsd:element name="price"  type="xsd:decimal"/>
  </xsd:sequence>
  <xsd:attribute name="genre" type="xsd:string"/>
 </xsd:complexType>

 <xsd:complexType name="authorName">
  <xsd:sequence>
   <xsd:element name="first-name"  type="xsd:string"/>
   <xsd:element name="last-name" type="xsd:string"/>
  </xsd:sequence>
 </xsd:complexType>

</xsd:schema>

OutputOutput

验证错误:未声明“publisher”属性。Validation Error: The 'publisher' attribute is not declared.

注解

备注

XmlNodeReader建议你XmlReader 使用XmlReaderSettings类和方法创建实例,而不是使用。CreateInstead of using the XmlNodeReader, we recommend that you create XmlReader instances by using the XmlReaderSettings class and the Create method. 这使您可以利用对 XML 1.0 建议的一致性检查和符合性。This enables you to take advantage of conformance checking and compliance to the XML 1.0 recommendation.

XmlNodeReader能够读取 XML DOM 子树。The XmlNodeReader has the ability to read an XML DOM subtree. 此类不支持文档类型定义 (DTD) 或架构验证。This class does not support document type definition (DTD) or schema validation. 但是, 你可以创建一个XmlReader对象, 该对象环绕XmlNodeReader对象来验证存储在XmlNodeReader对象中的数据, 如 "示例" 部分所示。However, you can create an XmlReader object that wraps around the XmlNodeReader object to validate the data stored in the XmlNodeReader object, as shown in Examples section.

构造函数

XmlNodeReader(XmlNode) XmlNodeReader(XmlNode) XmlNodeReader(XmlNode) XmlNodeReader(XmlNode)

使用指定的 XmlNode 创建 XmlNodeReader 类的实例。Creates an instance of the XmlNodeReader class using the specified XmlNode.

属性

AttributeCount AttributeCount AttributeCount AttributeCount

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

BaseURI BaseURI BaseURI BaseURI

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

CanReadBinaryContent CanReadBinaryContent CanReadBinaryContent CanReadBinaryContent

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

CanReadValueChunk CanReadValueChunk CanReadValueChunk CanReadValueChunk

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

(Inherited from XmlReader)
CanResolveEntity CanResolveEntity CanResolveEntity CanResolveEntity

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

Depth Depth Depth Depth

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

EOF EOF EOF EOF

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

HasAttributes HasAttributes HasAttributes HasAttributes

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

HasValue HasValue HasValue HasValue

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

IsDefault IsDefault IsDefault IsDefault

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

IsEmptyElement IsEmptyElement IsEmptyElement IsEmptyElement

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

Item[String, String] Item[String, String] Item[String, String] Item[String, String]

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

Item[String] Item[String] Item[String] Item[String]
LocalName LocalName LocalName LocalName

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

Name Name Name Name

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

NamespaceURI NamespaceURI NamespaceURI NamespaceURI

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

NameTable NameTable NameTable NameTable

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

NodeType NodeType NodeType NodeType

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

Prefix Prefix Prefix Prefix

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

QuoteChar QuoteChar QuoteChar QuoteChar

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

ReadState ReadState ReadState ReadState

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

SchemaInfo SchemaInfo SchemaInfo SchemaInfo

获取已分配给当前节点的架构信息。Gets the schema information that has been assigned to the current node.

Settings Settings Settings Settings

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

(Inherited from XmlReader)
Value Value Value Value

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

ValueType ValueType ValueType ValueType

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

(Inherited from XmlReader)
XmlLang XmlLang XmlLang XmlLang

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

XmlSpace XmlSpace XmlSpace XmlSpace

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

方法

Close() Close() Close() Close()

ReadState 改为 ClosedChanges the ReadState to Closed.

Dispose() Dispose() Dispose() Dispose()

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

(Inherited from XmlReader)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

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

(Inherited from XmlReader)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetAttribute(Int32) GetAttribute(Int32) GetAttribute(Int32) GetAttribute(Int32)

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

GetAttribute(String) GetAttribute(String) GetAttribute(String) GetAttribute(String)

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

GetAttribute(String, String) GetAttribute(String, String) GetAttribute(String, String) GetAttribute(String, String)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
GetValueAsync() GetValueAsync() GetValueAsync() GetValueAsync()

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

(Inherited from XmlReader)
IsStartElement() IsStartElement() IsStartElement() IsStartElement()

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

(Inherited from XmlReader)
IsStartElement(String) IsStartElement(String) IsStartElement(String) 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.

(Inherited from XmlReader)
IsStartElement(String, String) IsStartElement(String, String) IsStartElement(String, String) 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.

(Inherited from XmlReader)
LookupNamespace(String) LookupNamespace(String) LookupNamespace(String) LookupNamespace(String)

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

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
MoveToAttribute(Int32) MoveToAttribute(Int32) MoveToAttribute(Int32) MoveToAttribute(Int32)

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

MoveToAttribute(String) MoveToAttribute(String) MoveToAttribute(String) MoveToAttribute(String)

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

MoveToAttribute(String, String) MoveToAttribute(String, String) MoveToAttribute(String, String) MoveToAttribute(String, String)

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

MoveToContent() MoveToContent() MoveToContent() 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.

(Inherited from XmlReader)
MoveToContentAsync() MoveToContentAsync() MoveToContentAsync() 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.

(Inherited from XmlReader)
MoveToElement() MoveToElement() MoveToElement() MoveToElement()

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

MoveToFirstAttribute() MoveToFirstAttribute() MoveToFirstAttribute() MoveToFirstAttribute()

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

MoveToNextAttribute() MoveToNextAttribute() MoveToNextAttribute() MoveToNextAttribute()

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

Read() Read() Read() Read()

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

ReadAsync() ReadAsync() ReadAsync() ReadAsync()

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

(Inherited from XmlReader)
ReadAttributeValue() ReadAttributeValue() ReadAttributeValue() ReadAttributeValue()

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

ReadContentAs(Type, IXmlNamespaceResolver) ReadContentAs(Type, IXmlNamespaceResolver) ReadContentAs(Type, IXmlNamespaceResolver) ReadContentAs(Type, IXmlNamespaceResolver)

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

(Inherited from XmlReader)
ReadContentAsAsync(Type, IXmlNamespaceResolver) ReadContentAsAsync(Type, IXmlNamespaceResolver) ReadContentAsAsync(Type, IXmlNamespaceResolver) ReadContentAsAsync(Type, IXmlNamespaceResolver)

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

(Inherited from XmlReader)
ReadContentAsBase64(Byte[], Int32, Int32) ReadContentAsBase64(Byte[], Int32, Int32) ReadContentAsBase64(Byte[], Int32, Int32) ReadContentAsBase64(Byte[], Int32, Int32)

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

ReadContentAsBase64Async(Byte[], Int32, Int32) ReadContentAsBase64Async(Byte[], Int32, Int32) ReadContentAsBase64Async(Byte[], Int32, Int32) ReadContentAsBase64Async(Byte[], Int32, Int32)

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

(Inherited from XmlReader)
ReadContentAsBinHex(Byte[], Int32, Int32) ReadContentAsBinHex(Byte[], Int32, Int32) ReadContentAsBinHex(Byte[], Int32, Int32) ReadContentAsBinHex(Byte[], Int32, Int32)

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

ReadContentAsBinHexAsync(Byte[], Int32, Int32) ReadContentAsBinHexAsync(Byte[], Int32, Int32) ReadContentAsBinHexAsync(Byte[], Int32, Int32) ReadContentAsBinHexAsync(Byte[], Int32, Int32)

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

(Inherited from XmlReader)
ReadContentAsBoolean() ReadContentAsBoolean() ReadContentAsBoolean() ReadContentAsBoolean()

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

(Inherited from XmlReader)
ReadContentAsDateTime() ReadContentAsDateTime() ReadContentAsDateTime() ReadContentAsDateTime()

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

(Inherited from XmlReader)
ReadContentAsDateTimeOffset() ReadContentAsDateTimeOffset() ReadContentAsDateTimeOffset() ReadContentAsDateTimeOffset()

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

(Inherited from XmlReader)
ReadContentAsDecimal() ReadContentAsDecimal() ReadContentAsDecimal() ReadContentAsDecimal()

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

(Inherited from XmlReader)
ReadContentAsDouble() ReadContentAsDouble() ReadContentAsDouble() ReadContentAsDouble()

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

(Inherited from XmlReader)
ReadContentAsFloat() ReadContentAsFloat() ReadContentAsFloat() ReadContentAsFloat()

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

(Inherited from XmlReader)
ReadContentAsInt() ReadContentAsInt() ReadContentAsInt() ReadContentAsInt()

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

(Inherited from XmlReader)
ReadContentAsLong() ReadContentAsLong() ReadContentAsLong() ReadContentAsLong()

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

(Inherited from XmlReader)
ReadContentAsObject() ReadContentAsObject() ReadContentAsObject() ReadContentAsObject()

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

(Inherited from XmlReader)
ReadContentAsObjectAsync() ReadContentAsObjectAsync() ReadContentAsObjectAsync() ReadContentAsObjectAsync()

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

(Inherited from XmlReader)
ReadContentAsString() ReadContentAsString() ReadContentAsString() ReadContentAsString()

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

(Inherited from XmlReader)
ReadContentAsStringAsync() ReadContentAsStringAsync() ReadContentAsStringAsync() ReadContentAsStringAsync()

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

(Inherited from XmlReader)
ReadElementContentAs(Type, IXmlNamespaceResolver) ReadElementContentAs(Type, IXmlNamespaceResolver) ReadElementContentAs(Type, IXmlNamespaceResolver) ReadElementContentAs(Type, IXmlNamespaceResolver)

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

(Inherited from XmlReader)
ReadElementContentAs(Type, IXmlNamespaceResolver, String, String) ReadElementContentAs(Type, IXmlNamespaceResolver, String, String) ReadElementContentAs(Type, IXmlNamespaceResolver, String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsAsync(Type, IXmlNamespaceResolver) ReadElementContentAsAsync(Type, IXmlNamespaceResolver) ReadElementContentAsAsync(Type, IXmlNamespaceResolver) ReadElementContentAsAsync(Type, IXmlNamespaceResolver)

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

(Inherited from XmlReader)
ReadElementContentAsBase64(Byte[], Int32, Int32) ReadElementContentAsBase64(Byte[], Int32, Int32) ReadElementContentAsBase64(Byte[], Int32, Int32) ReadElementContentAsBase64(Byte[], Int32, Int32)

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

ReadElementContentAsBase64Async(Byte[], Int32, Int32) ReadElementContentAsBase64Async(Byte[], Int32, Int32) ReadElementContentAsBase64Async(Byte[], Int32, Int32) ReadElementContentAsBase64Async(Byte[], Int32, Int32)

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

(Inherited from XmlReader)
ReadElementContentAsBinHex(Byte[], Int32, Int32) ReadElementContentAsBinHex(Byte[], Int32, Int32) ReadElementContentAsBinHex(Byte[], Int32, Int32) ReadElementContentAsBinHex(Byte[], Int32, Int32)

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

ReadElementContentAsBinHexAsync(Byte[], Int32, Int32) ReadElementContentAsBinHexAsync(Byte[], Int32, Int32) ReadElementContentAsBinHexAsync(Byte[], Int32, Int32) ReadElementContentAsBinHexAsync(Byte[], Int32, Int32)

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

(Inherited from XmlReader)
ReadElementContentAsBoolean() ReadElementContentAsBoolean() ReadElementContentAsBoolean() ReadElementContentAsBoolean()

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

(Inherited from XmlReader)
ReadElementContentAsBoolean(String, String) ReadElementContentAsBoolean(String, String) ReadElementContentAsBoolean(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsDateTime() ReadElementContentAsDateTime() ReadElementContentAsDateTime() ReadElementContentAsDateTime()

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

(Inherited from XmlReader)
ReadElementContentAsDateTime(String, String) ReadElementContentAsDateTime(String, String) ReadElementContentAsDateTime(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsDecimal() ReadElementContentAsDecimal() ReadElementContentAsDecimal() ReadElementContentAsDecimal()

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

(Inherited from XmlReader)
ReadElementContentAsDecimal(String, String) ReadElementContentAsDecimal(String, String) ReadElementContentAsDecimal(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsDouble() ReadElementContentAsDouble() ReadElementContentAsDouble() ReadElementContentAsDouble()

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

(Inherited from XmlReader)
ReadElementContentAsDouble(String, String) ReadElementContentAsDouble(String, String) ReadElementContentAsDouble(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsFloat() ReadElementContentAsFloat() ReadElementContentAsFloat() ReadElementContentAsFloat()

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

(Inherited from XmlReader)
ReadElementContentAsFloat(String, String) ReadElementContentAsFloat(String, String) ReadElementContentAsFloat(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsInt() ReadElementContentAsInt() ReadElementContentAsInt() ReadElementContentAsInt()

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

(Inherited from XmlReader)
ReadElementContentAsInt(String, String) ReadElementContentAsInt(String, String) ReadElementContentAsInt(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsLong() ReadElementContentAsLong() ReadElementContentAsLong() ReadElementContentAsLong()

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

(Inherited from XmlReader)
ReadElementContentAsLong(String, String) ReadElementContentAsLong(String, String) ReadElementContentAsLong(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsObject() ReadElementContentAsObject() ReadElementContentAsObject() ReadElementContentAsObject()

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

(Inherited from XmlReader)
ReadElementContentAsObject(String, String) ReadElementContentAsObject(String, String) ReadElementContentAsObject(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsObjectAsync() ReadElementContentAsObjectAsync() ReadElementContentAsObjectAsync() ReadElementContentAsObjectAsync()

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

(Inherited from XmlReader)
ReadElementContentAsString() ReadElementContentAsString() ReadElementContentAsString() ReadElementContentAsString()

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

(Inherited from XmlReader)
ReadElementContentAsString(String, String) ReadElementContentAsString(String, String) ReadElementContentAsString(String, String) 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.

(Inherited from XmlReader)
ReadElementContentAsStringAsync() ReadElementContentAsStringAsync() ReadElementContentAsStringAsync() ReadElementContentAsStringAsync()

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

(Inherited from XmlReader)
ReadElementString() ReadElementString() ReadElementString() 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.

(Inherited from XmlReader)
ReadElementString(String) ReadElementString(String) ReadElementString(String) 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.

(Inherited from XmlReader)
ReadElementString(String, String) ReadElementString(String, String) ReadElementString(String, String) 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.

(Inherited from XmlReader)
ReadEndElement() ReadEndElement() ReadEndElement() ReadEndElement()

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

(Inherited from XmlReader)
ReadInnerXml() ReadInnerXml() ReadInnerXml() ReadInnerXml()

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

(Inherited from XmlReader)
ReadInnerXmlAsync() ReadInnerXmlAsync() ReadInnerXmlAsync() ReadInnerXmlAsync()

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

(Inherited from XmlReader)
ReadOuterXml() ReadOuterXml() ReadOuterXml() ReadOuterXml()

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

(Inherited from XmlReader)
ReadOuterXmlAsync() ReadOuterXmlAsync() ReadOuterXmlAsync() ReadOuterXmlAsync()

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

(Inherited from XmlReader)
ReadStartElement() ReadStartElement() ReadStartElement() ReadStartElement()

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

(Inherited from XmlReader)
ReadStartElement(String) ReadStartElement(String) ReadStartElement(String) ReadStartElement(String)

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

(Inherited from XmlReader)
ReadStartElement(String, String) ReadStartElement(String, String) ReadStartElement(String, String) 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.

(Inherited from XmlReader)
ReadString() ReadString() ReadString() ReadString()

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

ReadSubtree() ReadSubtree() ReadSubtree() ReadSubtree()

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

(Inherited from XmlReader)
ReadToDescendant(String) ReadToDescendant(String) ReadToDescendant(String) ReadToDescendant(String)

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

(Inherited from XmlReader)
ReadToDescendant(String, String) ReadToDescendant(String, String) ReadToDescendant(String, String) ReadToDescendant(String, String)

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

(Inherited from XmlReader)
ReadToFollowing(String) ReadToFollowing(String) ReadToFollowing(String) ReadToFollowing(String)

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

(Inherited from XmlReader)
ReadToFollowing(String, String) ReadToFollowing(String, String) ReadToFollowing(String, String) ReadToFollowing(String, String)

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

(Inherited from XmlReader)
ReadToNextSibling(String) ReadToNextSibling(String) ReadToNextSibling(String) ReadToNextSibling(String)

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

(Inherited from XmlReader)
ReadToNextSibling(String, String) ReadToNextSibling(String, String) ReadToNextSibling(String, String) ReadToNextSibling(String, String)

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

(Inherited from XmlReader)
ReadValueChunk(Char[], Int32, Int32) ReadValueChunk(Char[], Int32, Int32) ReadValueChunk(Char[], Int32, Int32) ReadValueChunk(Char[], Int32, Int32)

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

(Inherited from XmlReader)
ReadValueChunkAsync(Char[], Int32, Int32) ReadValueChunkAsync(Char[], Int32, Int32) ReadValueChunkAsync(Char[], Int32, Int32) ReadValueChunkAsync(Char[], Int32, Int32)

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

(Inherited from XmlReader)
ResolveEntity() ResolveEntity() ResolveEntity() ResolveEntity()

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

Skip() Skip() Skip() Skip()

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

SkipAsync() SkipAsync() SkipAsync() SkipAsync()

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

(Inherited from XmlReader)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

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

(Inherited from XmlReader)
IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope) IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope) IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope) IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope)

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

IXmlNamespaceResolver.LookupNamespace(String) IXmlNamespaceResolver.LookupNamespace(String) IXmlNamespaceResolver.LookupNamespace(String) IXmlNamespaceResolver.LookupNamespace(String)

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

IXmlNamespaceResolver.LookupPrefix(String) IXmlNamespaceResolver.LookupPrefix(String) IXmlNamespaceResolver.LookupPrefix(String) IXmlNamespaceResolver.LookupPrefix(String)

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

适用于