XmlReader.ReadElementContentAsBase64 メソッド
アセンブリ: System.Xml (system.xml.dll 内)

Public Overridable Function ReadElementContentAsBase64 ( _ buffer As Byte(), _ index As Integer, _ count As Integer _ ) As Integer
Dim instance As XmlReader Dim buffer As Byte() Dim index As Integer Dim count As Integer Dim returnValue As Integer returnValue = instance.ReadElementContentAsBase64(buffer, index, count)
public: virtual int ReadElementContentAsBase64 ( array<unsigned char>^ buffer, int index, int count )
戻り値
バッファに書き込まれたバイト数。


このメソッドは、要素のコンテンツを読み取り、Base64 エンコーディングを使用してコンテンツをデコードしてから、デコードされたバイナリ バイト (Base64 でエンコードされたインライン GIF イメージなど) をバッファに返します。詳細については、RFC 1521『MIME (Multipurpose Internet Mail Exensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies』を参照してください。RFC は、http://www.rfc-editor.org にある Request for Comments の Web サイトから取得できます。
ReadElementContentAsBase64 で読み取ることができるのは、単純なコンテンツを含む要素のみです。要素には、テキスト、空白、有意の空白、CDATA セクション、コメント、および処理命令を含めることができます。また、エンティティ参照を含めることもでき、含めた場合は自動的に展開されます。要素が子要素を持つことはできません。
このメソッドは ReadContentAsBase64 メソッドに非常に似ていますが、このメソッドを呼び出すことができるのは要素ノード型に対してのみです。
count 値がドキュメント内のバイト数よりも大きい、または同じである場合は、XmlReader はドキュメント内の残りのバイトをすべて読み取り、読み取ったバイト数を返します。次の XmlReader メソッド呼び出しはゼロを返して、EndElement の次のノードにリーダーを移動します。
要素のすべてのコンテンツが処理される前に Read を呼び出すと、リーダーは、最初のコンテンツが処理された後で Read メソッドが呼び出された場合のように動作することがあります。つまりリーダーは、末尾の要素に到達するまですべてのテキストを読み取ります。次に終了タグ ノードを読み取り、次のノードを読み取ってから、後続のノード上に自身を配置します。

インライン Base64 でエンコードされたイメージを読み取る例を次に示します。Base64 データは、<image> 要素内に埋め込まれます。BinaryWriter は、新しいバイナリ データ ファイルを作成するために使用されます。
Public Shared Sub Base64DecodeImageFile() 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 Base64 data. Console.WriteLine(vbCr + vbLf + "Reading Base64...") Dim bw As New BinaryWriter(outputFile) readBytes = reader.ReadElementContentAsBase64(buffer, 0, 50) While (readBytes > 0) bw.Write(buffer, 0, readBytes) readBytes = reader.ReadElementContentAsBase64(buffer, 0, 50) End While outputFile.Close() End Using End Sub 'Base64DecodeImageFile
public static void Base64DecodeImageFile() { 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 Base64 data. Console.WriteLine("\r\nReading Base64..."); BinaryWriter bw = new BinaryWriter(outputFile); while ((readBytes = reader.ReadElementContentAsBase64(buffer, 0, 50))>0) { bw.Write(buffer, 0, readBytes); } outputFile.Close(); } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からXmlReader.ReadElementContentAsBase64 メソッドを検索する場合は、下記のリンクをクリックしてください。

- XmlReader.ReadElementContentAsBase64 メソッドのページへのリンク