Reading binary data from Xml

Suppose that I have written binary data into an XML node like this:

MemoryBlock outputData( pOutputData, bytesToWrite );
pRegionXml->setAttribute( "OutputData", outputData.toBase64Encoding() );

How would I then read that data back in most efficiently? Is this correct? Is there a more efficient way?

MemoryBlock myData(2048);
if (myData.fromBase64Encoding( pMyXml->toString() ))
{...}

Since you’re writing the binary data to an attribute of the XML (“OutputData”), you’ll need to pass just the attribute value instead of the entire XML string to fromBase64Encoding().

1 Like

If you already turned the data into base64 encoding that is inside XML, I wouldn’t really worry anymore about how efficient it is to decode it back to binary. :slight_smile:

1 Like

Oh, right! I totally missed I was only writing an attribute, not converting an entire node to XML. D’oh! :slight_smile: Thanks!