XmlReader.ReadElementContentAsBinHex メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlReader.ReadElementContentAsBinHex メソッドの意味・解説 

XmlReader.ReadElementContentAsBinHex メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

要素読み取りBinHex内容デコードます。

名前空間: System.Xml
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Public Overridable Function
 ReadElementContentAsBinHex ( _
    buffer As Byte(), _
    index As Integer, _
    count As Integer _
) As Integer
public virtual int ReadElementContentAsBinHex
 (
    byte[] buffer,
    int index,
    int count
)
public:
virtual int ReadElementContentAsBinHex (
    array<unsigned char>^ buffer, 
    int index, 
    int count
)
public int ReadElementContentAsBinHex (
    byte[] buffer, 
    int index, 
    int count
)
public function ReadElementContentAsBinHex
 (
    buffer : byte[], 
    index : int, 
    count : int
) : int

パラメータ

buffer

結果として得られるテキストコピー先のバッファ。この値を null 参照 (Visual Basic では Nothing) にすることはできません。

index

バッファ内の結果コピー開始位置を示すオフセット

count

バッファコピーする最大バイト数。コピーされ実際バイト数は、このメソッドから返されます。

戻り値
バッファ書き込まれたバイト数。

例外例外
例外種類条件

ArgumentNullException

buffer 値が null 参照 (Visual Basic では Nothing) です。

InvalidOperationException

現在のノード要素ノードではありません。

ArgumentOutOfRangeException

バッファ内のインデックス、またはインデックスカウント合計値が、割り当てられているバッファ サイズ超えてます。

NotSupportedException

XmlReader 実装が、このメソッドサポートしていません。

XmlException

要素には混合コンテンツ含まれます。

FormatException

コンテンツ要求された型に変換できません。

解説解説

このメソッドは、要素コンテンツ読み取りBinHex エンコーディング使用してコンテンツデコードしてから、デコードされたバイナリ バイト (BinHexエンコードされたインライン GIF イメージなど) をバッファ返します

このメソッド読み取ることができるのは、単純なコンテンツを含む要素のみです。要素には、テキスト空白有意空白、CDATA セクションコメント、および処理命令含めることができますまた、エンティティ参照含めることもでき、含めた場合自動的に展開されます。要素子要素を持つことはできません。

このメソッドは ReadContentAsBinHex メソッドに非常に似ていますが、このメソッド呼び出すことができるのは要素ノードに対してのみです。

count 値がドキュメント内のバイト数よりも大きい、または同じである場合は、XmlReaderドキュメント内の残りバイトをすべて読み取り読み取ったバイト数を返します次の XmlReader メソッド呼び出しゼロ返してEndElement次のノードリーダー移動します

要素すべてのコンテンツ処理される前に Read呼び出すと、リーダーは、最初コンテンツ処理され後で Read メソッド呼び出され場合のように動作することがあります。つまりリーダーは、末尾要素到達するまですべてのテキスト読み取ります。次に終了タグ ノード読み取り次のノード読み取ってから、後続ノード上に自身配置します

使用例使用例

インライン BinHexエンコードされたイメージ読み取る例を次に示しますBinHex データは、<image> 要素内に埋め込まれます。BinaryWriter は、新しバイナリ データ ファイル作成するために使用されます。

Public Shared Sub BinHexDecodeImageFile()
 
    
    Dim buffer(999) As Byte
    Dim readBytes As Integer
 = 0
    
    Using reader As XmlReader = XmlReader.Create("output.xml")
            
            Dim outputFile As New
 FileStream("C:\artFiles\data\newImage.jpg", FileMode.OpenOrCreate,
 FileAccess.Write, FileShare.Write)
            ' Read to the image element.
            reader.ReadToFollowing("image")
            ' Read the BinHex data.
            Console.WriteLine(vbCr + vbLf + "Reading BinHex...")
            Dim bw As New
 BinaryWriter(outputFile)
            readBytes = reader.ReadElementContentAsBinHex(buffer, 0, 50)
            While (readBytes > 0)
                bw.Write(buffer, 0, readBytes)
                readBytes = reader.ReadElementContentAsBinHex(buffer, 0, 50)
            End While
            outputFile.Close()
        
    End Using

End Sub 'BinHexDecodeImageFile

public static void BinHexDecodeImageFile()
 {

  byte[] buffer = new byte[1000];
  int readBytes = 0;

  using (XmlReader reader = XmlReader.Create("output.xml"))
 {
                       
        FileStream outputFile = new FileStream(@"C:\artFiles\data\newImage.jpg",
 FileMode.OpenOrCreate, 
                                                                      FileAccess.Write,
 FileShare.Write);
        // Read to the image element.
        reader.ReadToFollowing("image");
        // Read the BinHex data.
        Console.WriteLine("\r\nReading BinHex...");
        BinaryWriter bw = new BinaryWriter(outputFile);
        while ((readBytes = reader.ReadElementContentAsBinHex(buffer,
 0, 50))>0) {
            bw.Write(buffer, 0, readBytes);
        }
        outputFile.Close();
        
  }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XmlReader.ReadElementContentAsBinHex メソッド」の関連用語

XmlReader.ReadElementContentAsBinHex メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlReader.ReadElementContentAsBinHex メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS