Carl Forsman
11/19/2008 7:46:00 AM
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[i].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[i].child(0).value();
//decode Base64 string into binary data
CString decoded = decodeBase64(cat);
//open file to write the binary data
std::ofstream file1("c:/test2.xml");
// write the decoded binary data to file
file1.write(decoded);
}
}