XmlNodeReader.ReadElementContentAsBinHex(Byte[], Int32, Int32) 方法
定义
读取元素并对 BinHex 内容进行解码。Reads the element and decodes the BinHex content.
public:
override int ReadElementContentAsBinHex(cli::array <System::Byte> ^ buffer, int index, int count);
public override int ReadElementContentAsBinHex (byte[] buffer, int index, int count);
override this.ReadElementContentAsBinHex : byte[] * int * int -> int
Public Overrides Function ReadElementContentAsBinHex (buffer As Byte(), index As Integer, count As Integer) As Integer
参数
- buffer
- Byte[]
结果文本复制到的缓冲区。The buffer into which to copy the resulting text. 此值不能为 null。This value cannot be null.
- index
- Int32
缓冲区中的偏移,从这个位置开始将结果复制到缓冲区中。The offset into the buffer where to start copying the result.
- count
- Int32
要复制到缓冲区的最大字节数。The maximum number of bytes to copy into the buffer. 此方法返回复制的实际字节数。The actual number of bytes copied is returned from this method.
返回
写入缓冲区的字节数。The number of bytes written to the buffer.
例外
buffer 值为 null。The buffer value is null.
当前节点不是元素节点。The current node is not an element node.
缓冲区中的索引或者索引与计数之和大于分配的缓冲区大小。The index into the buffer or index + count is larger than the allocated buffer size.
该元素包含混合内容。The element contains mixed content.
无法将内容转换成请求的类型。The content cannot be converted to the requested type.
示例
有关 XmlReader.ReadElementContentAsBinHex 使用此方法的示例,请参阅。See XmlReader.ReadElementContentAsBinHex to see an example using this method.
注解
备注
在 .NET Framework 2.0 中,建议的做法是 XmlReader 使用 XmlReaderSettings 类和方法创建实例 Create 。In the .NET Framework 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. 这允许您充分利用 .NET Framework 中引入的所有新功能。This allows you to take full advantage of all the new features introduced in the .NET Framework. 有关详细信息,请参阅 "参考" 页中的 "备注" 部分 XmlReader 。For more information, see the Remarks section in the XmlReader reference page.
此方法读取元素内容,使用 BinHex 编码对其进行解码,并返回解码的二进制字节 (例如,) 到缓冲区中的内联 BinHex 编码 GIF 图像。This method reads the element content, decodes it using BinHex encoding, and returns the decoded binary bytes (for example, an inline BinHex encoded GIF image) into the buffer.
此方法只能读取简单内容元素。This method can only read simple-content elements. 元素可以包含文本、空格、有效空白、CDATA 部分、注释和处理指令。The element can contain text, white space, significant white space, CDATA sections, comments and processing instructions. 它还可以包含自动扩展的实体引用。It can also contain entity references, which are automatically expanded. 元素不能有子元素。The element cannot have child elements.
此方法与方法非常类似, ReadContentAsBinHex 只是它只能在元素节点类型上调用。This method is very similar to the ReadContentAsBinHex method except that it can only be called on element node types.
如果 count 值大于文档中的字节数,或者它等于文档中的字节数,则 XmlNodeReader 读取文档中的所有剩余字节并返回读取的字节数。If the count value is higher than the number of bytes in the document, or if it is equal to the number of bytes in the document, the XmlNodeReader reads all the remaining bytes in the document and returns the number of bytes read. 下一 XmlNodeReader 方法调用返回零,并将读取器移动到节点后面的节点 EndElement 。The next XmlNodeReader method call returns a zero and moves the reader to the node following the EndElement node.
如果在 Read 所有元素内容被使用之前调用,则读取器的行为可能与先使用第一个内容,然后 Read 调用方法相同。If you call Read before all of the element content is consumed, the reader may behave as if the first content was consumed and then the Read method was called. 这意味着读取器将读取所有文本,直到遇到结束元素。This means that the reader reads all the text until the end element is encountered. 然后读取结束标记节点,读取下一个节点,然后在下一个后续节点上定位自身。It then reads the end tag node, read the next node, and then position itself on the next subsequent node.