473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Writing binary data (CString) to file

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);

}
}
Nov 19 '08 #1
0 2855

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: john smith | last post by:
Hi, I have a file format that is going to contain some parts in ascii, and some parts with raw binary data. Should I open this file with ios::bin or no? For example: filename: a.bin number of...
4
by: Delali Dzirasa | last post by:
Does anyone know of the fastest way to convert a CString of numbers ie "00000001" to the binary representation in an int? for example CString myVal = "00000001"; int myIntVal = 0; ...
6
by: Sebastian Kemi | last post by:
How should a write a class to a file? Would this example work: object *myobject = 0; tfile.write(reinterpret_cast<char *>(myobject), sizeof(*object)); / sebek
1
by: arrowlike | last post by:
In a VC6 program, a mscomm32.ocx is added to the project and read the binary incoming RS232 data stream (from a GPS receiver). I use another commercial serial port debug program to send out a...
4
by: jigi via DotNetMonster.com | last post by:
i have a compiled dll, and i want to see what values ar in certain methods during run time. i have built the release build . is there a way to write to a text file on my desktop or qa desktop? ...
3
by: nicolasg | last post by:
Hi, I'm trying to open a file (any file) in binary mode and save it inside a new text file. After that I want to read the source from the text file and save it back to the disk with its...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
5
by: zehra.mb | last post by:
Hi, I had written application for storing employee data in binary file and reading those data from binary file and display it in C language. But I face some issue with writing data to binary file....
0
by: Carl Forsman | last post by:
given the following base64_encode function, I will read bytes from a file and encode the binary data into a single line CString; but something wrong with the following code with errors! ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.