C# Decode Large/Huge XML / CDATA context in Base64
$15-20 USD
En curso
Publicado hace más de 11 años
$15-20 USD
Pagado a la entrega
I got a very large XML (>1GB) with CDATA content that contans a base64 with 76 characters and CRLF and the last content padded with "=" and no CRLF. The most natural way to get base64 decode is to use XmlReader [login to view URL](...) but thay stops working at 100Mb. (=OOM)
I found this after searching for a way to stream to Base64 conversion.
> string Original = "foo bar, this is an example";
>
> byte[] ToBase64; string Decoded;
>
> using ( MemoryStream ms = new MemoryStream() ) using ( CryptoStream cs = new CryptoStream( ms, new ToBase64Transform(), [login to view URL] ) ) using ( StreamWriter st = new StreamWriter( cs ) ) { [login to view URL]( Original ); [login to view URL](); ToBase64 = [login to view URL](); }
>
> using ( MemoryStream ms = new MemoryStream( ToBase64 ) ) using ( CryptoStream cs = new CryptoStream( ms, new FromBase64Transform(), [login to view URL] ) ) using ( StreamReader sr = new StreamReader( cs ) )
> { Decoded = [login to view URL](); }
>
> [login to view URL]( Original ); [login to view URL]( [login to view URL]( ToBase64 ) ); [login to view URL]( Decoded );
This example has a string as input but I need to convert this code to handle a file and start/stop reading from a position within the file.
> CData Start CDataEnd
> | |
> V V
>
>
>
> [xml..[Envelope]...[Body]base64 with 76 char + CRLF + padding "="...[/Body]...[/Envelope]