Writing binary data (CString) to file

C

Carl Forsman

I have some binary data encoded as Base64 encoding in an XML element
like this:

<data>TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx</data>

how can I extract this data -
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx

and save to a file say test2.xml

==================
pug::xml_node_list CategoryEntries;
PictureEntries.all_elements_by_name("category", CategoryEntries);

// if found XML element
if (CategoryEntries.size() > 0) {
for (unsigned int i = 0; i < CategoryEntries.size(); i++) {

//extract the Base64 string from XML element
//this Base64 string has binary data after decode
CString cat = CategoryEntries.child(0).value();

//decode Base64 string into binary data
CString decoded = decodeBase64(cat);

//open file to write the binary data
std::eek:fstream file1("c:/test2.xml");

// write the decoded binary data to file
file1.write(decoded);

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top